Update syntax error when saving

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

  1. Lyndonryder

    Lyndonryder New Member

    Joined:
    Mar 19, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
    
     
    Last edited by a moderator: Mar 20, 2012

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice