问题描述
对于上面给出的窗体,我想让用户登陆到此界面后将选择的信息能添加到数据库中,现在添加倒是可以实现,但是无法实现一一对应问题,就是说我无论用新用户还是老用户登陆,所选择出来的新信息都会显示在一行里,哪怕再次输入也一样,前面选择的信息将被覆盖,怎么样才能实现一一对应呢?以下是我这个窗体设计的代码.
ImportsSystem.DataImportsSystem.Data.OleDbPublicClassForm6InheritsSystem.Windows.Forms.FormDimstrAsString=""Dimstr1AsString=""Dimstr2AsString=""Dimstr3AsString=""Dimstr4AsString=""Dimstr5AsString=""PublicFunctionGetSqlStr(ByValstrAsString)AsStringReturnReplace(str,"'","''")EndFunctionPrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.ClickMe.Close()EndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickMe.Hide()DimyourformAsNewForm8yourform.Show()EndSubPrivateSubbtnUpdate_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesbtnUpdate.ClickDimselectcmdAsString="select*from注册登陆数据库whereid_number=2"DimconnStr,updateCmdAsStringconnStr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=database1.mdb"DimconnAsOleDbConnection,cmdAsOleDbCommand,myreaderAsOleDbDataReaderconn=NewOleDbConnection(connStr)conn.Open()cmd=NewOleDbCommand(selectcmd,conn)myreader=cmd.ExecuteReaderIfmyreader.ReadThenstr=myreader.Item("name1")EndIfconn.Close()conn=NewOleDbConnection(connStr)conn.Open()updateCmd="update注册登陆数据库Setcourse1='"&str1&"',course2='"&str2&"',course3='"&str3&"',course4='"&str4&"',course5='"&str5&"'wherename1='"&str&"'"cmd=NewOleDbCommand(updateCmd,conn)cmd.ExecuteNonQuery()MsgBox("恭喜您,选择类别成功!")conn.Close()EndSubPrivateSubCheckBox_CheckedChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Ifstr1=""Thenstr1=sender.TextElseIfstr2=""Thenstr2=sender.TextElseIfstr3=""Thenstr3=sender.TextElseIfstr4=""Thenstr4=sender.TextElseIfstr5=""Thenstr5=sender.TextEndIfEndSubPrivateSubForm6_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.LoadAddHandlerCheckBox1.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox2.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox3.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox4.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox5.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox6.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox7.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox8.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox9.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox10.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox11.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox12.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox13.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox14.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox15.CheckedChanged,AddressOfCheckBox_CheckedChangedAddHandlerCheckBox16.CheckedChanged,AddressOfCheckBox_CheckedChangedEndSubEndClass
解决方案
解决方案二:
你的id_number跟name1有什么关系呢