0

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")
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Keidi
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.