Problem with the OleDb.OleDbCommandBuilder

  • Thread starter Thread starter Sven Buggermann
  • Start date Start date
S

Sven Buggermann

Hi all,
Since my experience with sql is just beginning to grow
i use the commandbuilder object to generate updatecommands deletecommands
insertcommands.
With first run th update works without a problem
when i call my update function again (changing the same row again) i get
"Concurrency violation: the UpdateCommand affected 0 records."
Exception
The debugger shows that the dataset.datatable.row.rowstate = modified
But the update simply doesn't work

Does anyone know what i am doing wrong ?
any help would be greatly appreciated
Thanks & regards
Sven

Code:

For i = 0 to ds.tables.count -1
da.SelectCommand = New OleDb.OleDbCommand("SELECT * FROM " &
ds.Tables(i).TableName, mConnection)

comm = New OleDb.OleDbCommandBuilder(da)

da.UpdateCommand = comm.GetUpdateCommand
da.DeleteCommand = comm.GetDeleteCommand
da.InsertCommand = comm.GetInsertCommand

rowsaffected = da.Update(ds.Tables(i))
Debug.WriteLine("Updated table: " & ds.Tables(i).TableName & " affected
rows: " & rowsaffected)
Next
 
1) See my article on the CommandBuilder.
http://www.betav.com/msdn_magazine.htm
2) You don't need to move the Commands out of the Command builder for the
Update method to use them.
3) Turn on the Profiler and watch what's getting sent to the server. This
will tell you what SQL Server is being asked to do by ADO.NET.
4) Make sure you aren't calling AcceptChanges before the Update.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top