I write on MySQL 5.5, C#, ADO.NET, DataSet.
I have a DataSet and DataAdapter filled it. In DataAdapter I override INSERT, UPDATE, DELETE commands. When I use stored procedures, as these commands, all is well.
However, when I use transactionns in this stored procedures, I get an exception:
Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.
What can I do with this errors?
Sample: http://dl.dropbox.com/u/46828938/DataGridSample.zip
To reproduce the problem: Delete row from Datagrid and press “Update” button.
DBConcurrencyException (“Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.”) reproduce on:”productDataAdapter.Update(dataSet, “Products”);” string.
I learning a lot of documentations about this problem (msdn, mysql forum, stackoverflow, etc) and see:
Check real concurrency or not possibility do additional queries:
insert: get last inserted row and comparision with inserted row.update: get updated row (by key for example) and comparision with updated row.delete: try get row (by key for example) and get null.Of course, all described above comparisions nessesary do in one logical bath / connection etc.
Unfortunately other way check ‘”Concurrency violation” or not on MySql’ isn’t exist. (In defference from others db servers).
I hope, that this information helps someone.