Row not found or changed. The row cannot be found or the row has been changed
Solution.
If it is not important data. You do not need to pay attention to concurrency.
A simple solution is
Open the dbml (LINQ) file and change "Update Check" in the object class to never.
Do not change the primary key (ID.
The second method does not require updating the records. Please use SQL statements directly without retrieving the entire data and then updating it. This may cause a conflict.
DC. executecommand ("Update [DBO]. [mytable] Set num = num + 1 where id = @ P0", M. ID );
Method 3.
Try
{
DC. submitchanges (system. Data. LINQ. conflictmode. continueonconflict );
}
Catch (system. Data. LINQ. changeconflictexception ex)
{
DC. changeconflicts. resolveall (refreshmode. keepcurrentvalues); // keep the current value
DC. changeconflicts. resolveall (refreshmode. overwritecurrentvalues); // keep the original update and discard the current value.
DC. changeconflicts. resolveall (refreshmode. keepchanges); // Save the current version if the original value is in conflict.
// Note: submitchanges () is required after the conflict is resolved. Otherwise, it is not updated to the database.
DB. submitchanges ();
}
Solution:
Open dbml (LINQ) file, and find your entity change the propery (field) "Update Check" to never