S
Simon Verona
I have a problem with some code..
I'm adding records to an jet database using a data-adapter and a dataset.
The dataset and data-adapter are created using the following code:
==== code ====
Dim Connection As New System.Data.OleDb.OleDbConnection
Dim DataAdapter As New System.Data.OleDb.OleDbDataAdapter
Dim DataSet As New DataSet
Dim vmc As Int32
Connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\dms\webs\vehicles.mdb"
Connection.Open()
DataAdapter = New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM
StockList", Connection)
DataAdapter.FillSchema(DataSet, SchemaType.Mapped, "StockList")
DataAdapter.Fill(DataSet, "StockList")
Dim CommandBuilder As System.Data.OleDb.OleDbCommandBuilder = New
OleDbCommandBuilder(DataAdapter)
DataAdapter.InsertCommand = CommandBuilder.GetInsertCommand
=== end of code ===
The Dataset is then updated row by row using an array :
===== code =====
Try
DataSet.Tables("StockList").Rows.Add(values)
Catch ex As Exception
Debug.WriteLine("Error : " & Ex.Message)
End Try
==== code ====
This doesn't cause any errors.
The data-adapter then updates the database using:
==== code =====
Try
DataAdapter.Update(DataSet.Tables("StockList"))
Catch ex As Exception
Debug.WriteLine("Error on Update : " & Ex.Message)
End Try
=============
This fails with the error : "Error on Update : Syntax error in INSERT INTO
statement."
I can't see how this can happen, nor what I need to do to debug the code!!
Any pointers?
Thanks in advance.
Simon
I'm adding records to an jet database using a data-adapter and a dataset.
The dataset and data-adapter are created using the following code:
==== code ====
Dim Connection As New System.Data.OleDb.OleDbConnection
Dim DataAdapter As New System.Data.OleDb.OleDbDataAdapter
Dim DataSet As New DataSet
Dim vmc As Int32
Connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\dms\webs\vehicles.mdb"
Connection.Open()
DataAdapter = New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM
StockList", Connection)
DataAdapter.FillSchema(DataSet, SchemaType.Mapped, "StockList")
DataAdapter.Fill(DataSet, "StockList")
Dim CommandBuilder As System.Data.OleDb.OleDbCommandBuilder = New
OleDbCommandBuilder(DataAdapter)
DataAdapter.InsertCommand = CommandBuilder.GetInsertCommand
=== end of code ===
The Dataset is then updated row by row using an array :
===== code =====
Try
DataSet.Tables("StockList").Rows.Add(values)
Catch ex As Exception
Debug.WriteLine("Error : " & Ex.Message)
End Try
==== code ====
This doesn't cause any errors.
The data-adapter then updates the database using:
==== code =====
Try
DataAdapter.Update(DataSet.Tables("StockList"))
Catch ex As Exception
Debug.WriteLine("Error on Update : " & Ex.Message)
End Try
=============
This fails with the error : "Error on Update : Syntax error in INSERT INTO
statement."
I can't see how this can happen, nor what I need to do to debug the code!!
Any pointers?
Thanks in advance.
Simon