更新数据库VB.NET Access 2010时da.Update()“语法错误”

时间:2013-09-12 12:56:37

标签: sql vb.net database-connection ms-access-2010

我是VB.Net数据库的初学者,我正在尝试更新数据库中的密码(字段)并且我一直收到错误:

  

“查询表达式中的语法错误”((UID =?)AND((?= 1 AND用户名IS NULL)或(用户名=?))AND((?= 1 AND Firstname} IS NULL)或(名字) =?))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

我将非常感谢任何帮助。谢谢你们!

0 个答案:

没有答案