S
Sébastien
Here is my code :
oldOleDbDataAdapter = New OleDb.OleDbDataAdapter("SELECT * FROM " &
strTable, strConnection)
oldOleDbCommandBuilder = New
OleDb.OleDbCommandBuilder(oldOleDbDataAdapter)
oldOleDbDataAdapter.Update(dtsDataSet, strTable)
dtsDataSet.Tables.Item(strTable).AcceptChanges
That code work perfectly when I add a new row (in ALL cases). But if I start
my software with no data in the strTable I want to update, and I add a new
row in that strTable, then I update it, it throw an exception (Concurrency
Exception 0 rows affected). Same thing if I start my software with an empty
strTable, I add a new row in strTable then I delete it, I get the same
error. BUT, if when I start the software with 1 or more rows in strTable, it
don't throw me any exception whatever I do.
That is a strange case. The only way I found to solve it is to create a
DataAdapter using the Wizard (so I drag and drop the OleDbDataAdapter from
the Toolbox on my form). Then in my code, I add something like :
oldOleDbDataAdapter.UpdateCommand = DataAdapterOnTheForm.UpdateCommand
I don't need to change the Insert statement created with the CommandBuilder.
Does anybody have an idea about this problem ?
Thank you for your help.
oldOleDbDataAdapter = New OleDb.OleDbDataAdapter("SELECT * FROM " &
strTable, strConnection)
oldOleDbCommandBuilder = New
OleDb.OleDbCommandBuilder(oldOleDbDataAdapter)
oldOleDbDataAdapter.Update(dtsDataSet, strTable)
dtsDataSet.Tables.Item(strTable).AcceptChanges
That code work perfectly when I add a new row (in ALL cases). But if I start
my software with no data in the strTable I want to update, and I add a new
row in that strTable, then I update it, it throw an exception (Concurrency
Exception 0 rows affected). Same thing if I start my software with an empty
strTable, I add a new row in strTable then I delete it, I get the same
error. BUT, if when I start the software with 1 or more rows in strTable, it
don't throw me any exception whatever I do.
That is a strange case. The only way I found to solve it is to create a
DataAdapter using the Wizard (so I drag and drop the OleDbDataAdapter from
the Toolbox on my form). Then in my code, I add something like :
oldOleDbDataAdapter.UpdateCommand = DataAdapterOnTheForm.UpdateCommand
I don't need to change the Insert statement created with the CommandBuilder.
Does anybody have an idea about this problem ?
Thank you for your help.