1

我是 VB.Net 数据库的初学者,正在尝试更新数据库中的密码(字段),但我不断收到错误消息:

“查询表达式中的语法错误 '((UID = ?) AND ((? = 1 AND Username IS NULL) OR (Username = ?)) AND ((? = 1 AND Firstname} IS NULL) OR (Firstname} = ?) ) AND ((? = 1 AND Surname IS NULL) OR (Surname = ?)) AND ((? = 1 AND UPassword IS NULL) OR (UPassword = ?)) AND ((? = 1 AND DOB IS NULL)'。 "

这是它对应的表单的代码,并在单击重置按钮时发生。

Public Class ResetPW
    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim sql As String
    Dim dbProvider As String
    Dim dbSource As String
    Dim da As New OleDb.OleDbDataAdapter

    Private Sub cbxShowchar_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxShowchar.CheckedChanged
        If cbxShowchar.Checked = True Then
            txtNewpassword.PasswordChar = ""
            txtVNewpassword.PasswordChar = ""
        Else
            txtNewpassword.PasswordChar = "*"
            txtVNewpassword.PasswordChar = "*"
        End If
    End Sub

    Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
        Me.Close()
        Form2.Show()
    End Sub

    Private Sub ResetPW_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
        dbSource = "DATA Source = C:\Users\Luke\Dropbox\FdSc Computing\Year 2\Project\Product\Book Database.accdb"
        con.ConnectionString = dbProvider & dbSource
        con.Open()
        sql = "SELECT * FROM T_Users"
        da = New OleDb.OleDbDataAdapter(Sql, con)
        da.Fill(ds, "Users")
        MsgBox("The database is now open")
        con.Close()
        MsgBox("The database is now closed")
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        If txtNewpassword.Text = txtVNewpassword.Text Then
            Dim cb As New OleDb.OleDbCommandBuilder(da)
            ds.Tables("Users").Rows(0).Item(4) = txtNewpassword.Text
            da.Update(ds, "Users")                      'ERROR HAPPENS HERE'
            MsgBox("Password Reset", vbInformation)
        Else
            MsgBox("The passwords do not match", vbExclamation)
        End If
    End Sub
End Class

如果有任何帮助,我将不胜感激。多谢你们!

4

0 回答 0