这是我的代码。但它不会对表值的多次更新起作用,它只在我更新单个值时才起作用。请帮助我,我是新手:(
Private Sub SaveChanges_Click(sender As System.Object, e As System.EventArgs) Handles SaveChanges.Click
Dim con As New MySqlConnection("host = localhost; username = root; password = 1234; database = logindb")
Dim cmd As New MySqlCommand
con.Open()
cmd.Connection = con
cmd.CommandText = "UPDATE login SET username = '" & ChangeUsername.Text & "' and password = '" & ChangePassword.Text & "' and Security_Question1 ='" & ChangeSecQue1.Text & "' and Security_Question2 = '" & ChangeSecQue2.Text & "' and Security_Answer1 = '" & ChangeSecAns1.Text & "' and Security_Answer2 = '" & ChangeSecAns2.Text & "' "
cmd.ExecuteNonQuery()
MsgBox("Saved Changes!")
con.Close()
End Sub
答案 0 :(得分:0)
更改您的更新声明:
cmd.CommandText = "UPDATE login SET username = '" & ChangeUsername.Text & "' ,password = '" & ChangePassword.Text & "' ,Security_Question1 ='" & ChangeSecQue1.Text & "' ,Security_Question2 = '" & ChangeSecQue2.Text & "' ,Security_Answer1 = '" & ChangeSecAns1.Text & "' ,Security_Answer2 = '" & ChangeSecAns2.Text & "' "