提问人:Jiyu 提问时间:12/6/2022 更新时间:12/6/2022 访问量:37
如何一键添加两个表中的数据并同时删除数据?
How to add data in two tables and delete data at the same time using one button?
问:
“我的学生注册表中有问题,我想将我的学生信息插入到我的不同数据库中。
学生信息表
ICT、ABM和HE课程表
我还想插入、更新、删除这两个不同的数据库中插入的两个数据,只需一个按钮即可在 vb.net 中一个表单中插入”
connect()
if txtStudID = "" and txtF.text = "" and txtM.text = "" and txtS.text = "" then
messagebox.show("Please Complete the Data")
else
comm.Connection =conn
comm.Commandtext = "INSERT into MyDatabase values ('" & txtStudID.text & "', '" & txtF.text & "', '" & txtM.text & "', '" & txtS.text & "', '" & dtpDOB.text & "', '" & cboGender.text & "', '" & txtAge.text & "', '" & cboProg.text & "', '" & cboYr.text & "', '" & Source.text & "', '" & txtPhone.text & "', '" & txtEmail.text & "', '" & txtAddress.text & "', '" & RD.text & "')"
comm.ExecuteNonQuery()
populate()
Myclear()
end if
'to the second table
if cboProg.Text = ICT then
comm.Connection =conn
comm.Commandtext = "INSERT into ICT values ('" & txtStudID.text & "', '" & txtF.text & "', '" & txtM.text & "', '" & txtS.text & "', '" & dtpDOB.text & "', '" & cboGender.text & "', '" & txtAge.text & "', '" & cboProg.text & "', '" & cboYr.text & "', '" & Source.text & "', '" & txtPhone.text & "', '" & txtEmail.text & "', '" & txtAddress.text & "', '" & RD.text & "')"
comm.ExecuteNonQuery()
messagebox.show("Successfully Registered as an ICT STUDENT!")
elseif cboProg.Text = ABM then
comm.Connection =conn
comm.Commandtext = "INSERT into ABM values ('" & txtStudID.text & "', '" & txtF.text & "', '" & txtM.text & "', '" & txtS.text & "', '" & dtpDOB.text & "', '" & cboGender.text & "', '" & txtAge.text & "', '" & cboProg.text & "', '" & cboYr.text & "', '" & Source.text & "', '" & txtPhone.text & "', '" & txtEmail.text & "', '" & txtAddress.text & "', '" & RD.text & "')"
comm.ExecuteNonQuery()
messagebox.show("Successfully Registered as an ABM STUDENT!")
elseif cboProg.Text = HE then
comm.Connection =conn
comm.Commandtext = "INSERT into HE values ('" & txtStudID.text & "', '" & txtF.text & "', '" & txtM.text & "', '" & txtS.text & "', '" & dtpDOB.text & "', '" & cboGender.text & "', '" & txtAge.text & "', '" & cboProg.text & "', '" & cboYr.text & "', '" & Source.text & "', '" & txtPhone.text & "', '" & txtEmail.text & "', '" & txtAddress.text & "', '" & RD.text & "')"
comm.ExecuteNonQuery()
messagebox.show("Successfully Registered as an HE STUDENT!")
END IF
答: 暂无答案
评论