I'm keep getting this error message when I try to update to my database. It's an access database and I thought I everything right because I can view all the records but when I try to update it I get this message.
Syntax error (missing operator) in query expression '((ID = ?) AND ((? = 1 AND First Name IS NULL) OR (First Name = ?)) AND ((? = 1 AND Last Name IS NULL) OR (Last Name = ?)) AND ((? = 1 AND Address IS NULL) OR (Address = ?)) AND ((? = 1 AND City IS NULL) OR (City = ?)) AND ((? = 1 AND State IS NULL) OR (St'.
Here is where I make the connection.
rivate Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\AddressBook1.mdb"
con.Open()
sql = "SELECT * FROM tblContacts"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
con.Close()
MaxRows = ds.Tables("AddressBook").Rows.Count
inc = -1
End Sub
Here is the code for my update button.
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("AddressBook").Rows(inc).Item(1) = firstTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(2) = lastTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(3) = addressTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(4) = cityTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(5) = stateTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(6) = zipTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(7) = phoneTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(8) = cellTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(9) = emailTextBox.Text
ds.Tables("AddressBook").Rows(inc).Item(10) = birthdayTextBox.Text
da.Update(ds, "AddressBook")
MsgBox("Data updated")
Else
MsgBox("No Records Yet")
End If
End Sub
SOMEONE HELP PLEASE! I've been trying to figure this out for two days and this assignment it due tonight. thanks