1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Update syntax error when saving

Discussion in 'MS Access' started by Lyndonryder, Mar 19, 2012.

  1. Lyndonryder

    Lyndonryder New Member

    Mar 19, 2012
    Likes Received:
    Trophy Points:
    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?
    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
    '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")
    End Sub
    End Class
    Last edited by a moderator: Mar 20, 2012

Share This Page