以下代码有什么问题。 它给出了语法错误。
str = "UPDATE Users SET Password=? WHERE User_Name=?"
cmd1 = New OleDbCommand(str, con)
cmd1.Parameters.AddWithValue("@Password", pwn)
cmd1.Parameters.AddWithValue("@User_Name", un)
cmd1.ExecuteNonQuery()
MsgBox("Password Updated Successfully")
答案 0 :(得分:0)
密码是使用[Password]
str = "UPDATE Users SET [Password]=? WHERE User_Name=?"
//str = "UPDATE Users SET [Password]=@Password WHERE User_Name=@User_Name"
cmd1 = New OleDbCommand(str, con)
cmd1.Parameters.AddWithValue("@Password", pwn)
cmd1.Parameters.AddWithValue("@User_Name", un)
cmd1.ExecuteNonQuery()
MsgBox("Password Updated Successfully")
答案 1 :(得分:0)
PASSWORD是reserved keyword,将您的代码更改为
str = "UPDATE Users SET [Password]=? WHERE User_Name=?"
cmd1 = New OleDbCommand(str, con)
cmd1.Parameters.AddWithValue("@Password", pwn)
cmd1.Parameters.AddWithValue("@User_Name", un)
cmd1.ExecuteNonQuery()
MsgBox("Password Updated Successfully")
顺便说一下,如果你仍然可以这样做,我建议将此列更改为非保留字,否则每次都会出现此问题