Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MS Access (http://www.go4expert.com/forums/ms-access-forum/)
-   -   Update syntax error when saving (http://www.go4expert.com/forums/update-syntax-error-saving-t28059/)

Lyndonryder 20Mar2012 04:58

Update syntax error when saving
 
I have been having trouble saving data from a VB2010 form back to MS Access.
I have written the following small test code but get the same result no matter how I code the Update statement. The Update statment always returns a syntax error. Any suggestions?
Code:

Public Class Form1
 
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter()
Dim OrdersTable As String
 
Private Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveButton.Click
 
'Open and access the orders database
dbProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
dbSource = "Data Source=c:\NFB Associates\Temple Books\VB Software\Database9.accdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
 
'Prepare 'Orders' table for access
OrdersTable = "SELECT * From Table1"
da = New OleDb.OleDbDataAdapter(OrdersTable, con)
da.Fill(ds, "Table1")
 
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("Table1").Rows(0).Item(0) = "888"
ds.Tables("Table1").Rows(0).Item(1) = "777"
 
da.Update(ds, "Table1")
con.Close()
 
End Sub
End Class



All times are GMT +5.5. The time now is 05:54.