如何在一个窗体中定义另一个窗体的事件,急~~~@!
对于上面给出的窗体,我想让用户登陆到此界面后将选择的信息能添加到数据库中,现在添加倒是可以实现,但是无法实现一一对应问题,就是说我无论用新用户还是老用户登陆,所选择出来的新信息都会显示在一行里,哪怕再次输入也一样,前面选择的信息将被覆盖,怎么样才能实现一一对应呢?以下是我这个窗体设计的代码.Imports System.Data
Imports System.Data.OleDb
Public Class Form6
Inherits System.Windows.Forms.Form
Dim str As String = ""
Dim str1 As String = ""
Dim str2 As String = ""
Dim str3 As String = ""
Dim str4 As String = ""
Dim str5 As String = ""
Public Function GetSqlStr(ByVal str As String) As String
Return Replace(str, "'", "''")
End Function
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
Dim yourform As New Form8
yourform.Show()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim selectcmd As String = "select * from 注册登陆数据库 where id_number=2"
Dim connStr, updateCmd As String
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database1.mdb"
Dim conn As OleDbConnection, cmd As OleDbCommand, myreader As OleDbDataReader
conn = New OleDbConnection(connStr)
conn.Open()
cmd = New OleDbCommand(selectcmd, conn)
myreader = cmd.ExecuteReader
If myreader.Read Then
str = myreader.Item("name1")
End If
conn.Close()
conn = New OleDbConnection(connStr)
conn.Open()
updateCmd = "update 注册登陆数据库 Set course1='" & str1 & "',course2='" & str2 & "',course3='" & str3 & "',course4='" & str4 & "',course5='" & str5 & "' where name1='" & str & "'"
cmd = New OleDbCommand(updateCmd, conn)
cmd.ExecuteNonQuery()
MsgBox("恭喜您,选择类别成功!")
conn.Close()
End Sub
Private Sub CheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
If str1 = "" Then
str1 = sender.Text
ElseIf str2 = "" Then
str2 = sender.Text
ElseIf str3 = "" Then
str3 = sender.Text
ElseIf str4 = "" Then
str4 = sender.Text
ElseIf str5 = "" Then
str5 = sender.Text
End If
End Sub
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler CheckBox1.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox2.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox3.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox4.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox5.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox6.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox7.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox8.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox9.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox10.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox11.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox12.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox13.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox14.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox15.CheckedChanged, AddressOf CheckBox_CheckedChanged
AddHandler CheckBox16.CheckedChanged, AddressOf CheckBox_CheckedChanged
End Sub
End Class --------------------编程问答-------------------- 你的id_number跟name1有什么关系呢
补充:.NET技术 , VB.NET