I am trying to populate an MS Access table using VB.Net through a connection string everything else seems to work except when I try to add a new row.
I get this error:
OleDbException was unhandled
Syntax error in INSERT INTO statement
Here is the code

[Dim MaxRows As Integer
    Dim con As New OleDb.OleDbConnection
    Dim sql As String
    Dim ds As New DataSet
    Dim inc As Integer
    Dim da As OleDb.OleDbDataAdapter
'the add Button code:
Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim NewRow As DataRow

        NewRow = ds.Tables("a").NewRow()

        NewRow.Item(0) = ""
        NewRow.Item(1) = ""
        NewRow.Item(2) = ""
        NewRow.Item(3) = Date.Today
        'Dim contnue As Boolean

        ds.Tables("a").Rows.Add(NewRow)
        da.Update(ds, "a")

Recommended Answers

All 2 Replies

Please use code tags when posting code:

[code=vb.net] ...code here

[/code]

You need to specify the Insert, Update, and Delete queries for the dataset. Use the IDE and "Add -- New Item -- DataSet". Right click and add a table adapter. The wizard will guide you through the steps to connection to your database. After that you will have a typed dataset you can work with in code. What you have will not work for anything other than possibly in-memory data editing.

Will try and see thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.