I seem to be getting the error "Syntax error in UPDATE statement." when attempting to update my database through visual studio 2008, using forms.

Here is the code for the connection:

Private Sub btnLoadDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadDB.Click

        Provider = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;"
        Source = "Data Source = F:\My Documents\Computing\COMP4\COMP4 CW\WND.accdb"

        connection.ConnectionString = Provider & Source


        sqlCode = "SELECT * FROM Newspapers"
        dAdapter = New OleDb.OleDbDataAdapter(sqlCode, connection)
        dAdapter.Fill(dSet, "Newspapers")

        MsgBox("Database Loaded.", MsgBoxStyle.Information)

        maxRows = dSet.Tables("Newspapers").Rows.Count
        incr = -1

    End Sub

The code for the update button on my form:

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

        Dim cBuilder As New OleDb.OleDbCommandBuilder(dAdapter)

        dSet.Tables("Newspapers").Rows(incr).Item(0) = txtPMID.Text
        dSet.Tables("Newspapers").Rows(incr).Item(1) = txtPMName.Text
        dSet.Tables("Newspapers").Rows(incr).Item(2) = txtPMPrice.Text

        dAdapter.Update(dSet, "Newspapers")

        MsgBox("The record was successfully updated", MsgBoxStyle.Information)
    End Sub

Any help would be greatly appreciated.



(p.s. I am using the following tutorial:

http://www.homeandlearn.co.uk/NET/nets12p9.html )

What is "cBuilder" doing for you?

The cBuilder is the command builder; it builds the sql strings.

When is it being used?

dAdapter.Update(dSet, "Newspapers")

In the above line. I'm sorry if I'm not being very clear, I'm a student, and I don't have the best teachers :(

Do you need to call


right before calling the Update on the Adapter?

I don't think I need to, no..

This article has been dead for over six months. Start a new discussion instead.