65.9K
CodeProject is changing. Read more.
Home

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (2 votes)

Dec 4, 2009

CPOL
viewsIcon

41049

hi all. i've just encountered a problem in C#: "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records". that is an exception raised when there is a mismatch between the time that the DataTable reads from the DB until the time it wants to update it. one can use 2...

hi all. i've just encountered a problem in C#:
"Concurrency violation: the UpdateCommand affected 0 of the expected 1 records".
that is an exception raised when there is a mismatch between the time that the DataTable reads from the DB until the time it wants to update it. one can use 2 functions: dataAdapter.Fill(dataTable) and dataAdapter.Update(dataTable) my problem was that i 1st made Fill(), then made changes to the table, than 2nd made Update(). until now it worked perfect. now when i want to make further Update() calls i get this Exception. after some hours...i've figured out that all u need to do is use dataTable.Clear() and than call the Fill() method again and it works perfect!