Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:42:56+00:00 2026-06-06T23:42:56+00:00

VB2010 I have one DataSet and I add multiple tables, I then fill in

  • 0

VB2010 I have one DataSet and I add multiple tables, I then fill in these tables, and then insert those records into an Access db.

    'create a new DataSet
    Dim dsNav As New DataSet

    'first table
    Dim daTrips As New OleDb.OleDbDataAdapter("SELECT * FROM Trips", connNav)
    daTrips.Fill(dsNav, "Trips")
    Dim cbTrips As New OleDb.OleDbCommandBuilder(daTrips)

   'second table
    Dim daCars = New OleDb.OleDbDataAdapter("SELECT * FROM Cars", connNavDb)
    daCars.Fill(dsNav, "Cars")
    Dim cbCars As New OleDb.OleDbCommandBuilder(daCars)

    'here i open a huge text file and depending on the data i encounter, I create
    'a new DataRow and add it to the appropriate table. i add many new rows to each
    'table. for example
    Dim dsNewRow As DataRow = {tblCars}.NewRow()
    dsNewRow.Item("CarId") = textline.Substring(0, 10)
    dsNewRow.Item("CarMake") = textline.Substring(11, 15)
    tblCars.Rows.Add(dsNewRow)

    'i finish reading the text file and filling up the tables in the one DataSet
    'now i want to insert those records into the Access db
    Dim rowCnt1 As Integer = daTrips.Update(dsNav, "Trips")
    Dim rowCnt2 As Integer = daCars.Update(dsNav, "Cars")

The first update works but on the second update I get the exception:

A first chance exception of type ‘System.Data.OleDb.OleDbException’ occurred in System.Data.dll
System.Data.OleDb.OleDbException (0x80040E14): Syntax error in INSERT INTO statement.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)

I’ve looked at various articles and they all suggest updating a database with one DataSet containing multiple DataTables is do-able, but just cant figure out why this is bombing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:42:59+00:00Added an answer on June 6, 2026 at 11:42 pm

    I wish to put everything discovered in comments as an answer

    1. Try to avoid fields using reserved keywords in your tables (also fields with spaces embedded)
    2. CommandBuilders needs primary key infos, so add a adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey to recover primary key informations from the db schema
    3. Use the same connection for the Update as for the Fill

      Dim dsNav As New DataSet 
      'first table 
      Dim daTrips As New OleDb.OleDbDataAdapter("SELECT * FROM Trips", connNav) 
      daTrips.MissingSchemaAction = MissingSchemaAction.AddWithKey 
      daTrips.Fill(dsNav, "Trips") 
      Dim cbTrips As New OleDb.OleDbCommandBuilder(daTrips) 
      
      'second table 
      Dim daCars = New OleDb.OleDbDataAdapter("SELECT * FROM Cars", connNav) 
      daCars.MissingSchemaAction = MissingSchemaAction.AddWithKey 
      daCars.Fill(dsNav, "Cars") 
      Dim cbCars As New OleDb.OleDbCommandBuilder(daCars) 
      
      'here i open a huge text file and depending on the data i encounter, I create 
      'a new DataRow and add it to the appropriate table. i add many new rows to each 
      'table. for example 
      Dim dsNewRow As DataRow = {tblCars}.NewRow() 
      dsNewRow.Item("CarId") = textline.Substring(0, 10) 
      dsNewRow.Item("CarMake") = textline.Substring(11, 15) 
      tblCars.Rows.Add(dsNewRow) 
      
      'i finish reading the text file and filling up the tables in the one DataSet 
      'now i want to insert those records into the Access db 
      Dim rowCnt1 As Integer = daTrips.Update(dsNav, "Trips") 
      Dim rowCnt2 As Integer = daCars.Update(dsNav, "Cars") 
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one solution in VS2010 containing two MVC 3 projects. These are two
Is it possible to have one Script# project and make multiple Javascript files out
I have two instances of VS2010 running on same machine.One VS instance has a
I have one web application and virtual application in Azure. They are separate projects
I have many projects I work on normally, but I have one that consumes
I have an rdlc that has a separately-defined dataset. The time has come that
I have one problem in which i simply want to know how i can
What is the best way to have one admin setup alerts for the entire
I have a set of charts in a form. These are canned charts and
I have a big VS2010 solution, which contains a bunch of C# projects. One

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.