Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Problems updating access database (http://www.programmingforums.org/showthread.php?t=15648)

TheFuture Apr 18th, 2008 10:40 AM

Problems updating access database
 
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
:

  1.         con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\AddressBook1.mdb"
  2.         con.Open()
  3.  
  4.         sql = "SELECT * FROM tblContacts"
  5.         da = New OleDb.OleDbDataAdapter(sql, con)
  6.  
  7.         da.Fill(ds, "AddressBook")
  8.  
  9.         con.Close()
  10.  
  11.         MaxRows = ds.Tables("AddressBook").Rows.Count
  12.         inc = -1
  13.  
  14.     End Sub
  15.  
  16. Here is the code for my update button.
  17.  
  18.  
  19.     Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
  20.         If inc <> -1 Then
  21.             Dim cb As New OleDb.OleDbCommandBuilder(da)
  22.             ds.Tables("AddressBook").Rows(inc).Item(1) = firstTextBox.Text
  23.             ds.Tables("AddressBook").Rows(inc).Item(2) = lastTextBox.Text
  24.             ds.Tables("AddressBook").Rows(inc).Item(3) = addressTextBox.Text
  25.             ds.Tables("AddressBook").Rows(inc).Item(4) = cityTextBox.Text
  26.             ds.Tables("AddressBook").Rows(inc).Item(5) = stateTextBox.Text
  27.             ds.Tables("AddressBook").Rows(inc).Item(6) = zipTextBox.Text
  28.             ds.Tables("AddressBook").Rows(inc).Item(7) = phoneTextBox.Text
  29.             ds.Tables("AddressBook").Rows(inc).Item(8) = cellTextBox.Text
  30.             ds.Tables("AddressBook").Rows(inc).Item(9) = emailTextBox.Text
  31.             ds.Tables("AddressBook").Rows(inc).Item(10) = birthdayTextBox.Text
  32.  
  33.             da.Update(ds, "AddressBook")
  34.  
  35.             MsgBox("Data updated")
  36.         Else
  37.             MsgBox("No Records Yet")
  38.         End If
  39.  
  40.     End Sub

SOMEONE HELP PLEASE! I've been trying to figure this out for two days and this assignment it due tonight. thanks


All times are GMT -5. The time now is 1:24 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC