Concurrency violation problem.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Using ADO.NET Table adapter in C# , am updating a record using VS2005
generated update command by passing dataset and the assocaited table like;
this.CustomerDataSet.CustomerTable.

while updating am getting "Concurrency violation: the UpdateCommand affected
0 of the expected 1 records.".

Any help on this would be appreciated,

Thanks,
Pachu
 
Well, it seems like UPDATE command did not found a record to process.
When doing update DataAdapter sends UPDATE command to database and after
UPDATE has performed it asks DB "how many records did I update".

In this case DB says zero, and DataAdapter raised an exception.
Because it thinks that the reason for 0 updated records is that some
other client/session has deleted the record you wanted to update it
raises "Concurrency violation", but in fact the reason could be badly
written UPDATE command (look at the WHERE clause) or the fact that this
record never existed in DB.

Hope it helps,
Petar Repac
 
Back
Top