我的update
查询需要帮助。我明天需要完成这个。我认为我的代码是错误的。
我的表格:
我的数据库:
我的代码:
'user wants to change password
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connection As New OleDbConnection
connection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\db1.accdb;Persist Security Info=True")
Try
connection.Open()
Dim command As OleDbCommand = connection.CreateCommand
command.CommandType = CommandType.Text
command.CommandText = "Update UserAccount SET Password ='" + TextBox2.Text + "' WHERE Username = User"
command.ExecuteNonQuery()
MsgBox("Updated")z
TextBox2.Text = ""
TextBox3.Text = ""
Catch ex As Exception
MsgBox(ex.Message)
End Try
答案 0 :(得分:-1)
常见错误。问题出在这里:
... WHERE Username = User"
正在寻找名为User
的字段。
用户名实际上是用户吗?如果是这样,请用引号括起来:
... WHERE Username = 'User'"
用户实际上是一个持有用户名的变量吗?如果是这样的话:
... WHERE Username = '" & User & "'"