Dbconcurrencyexception occurs in updatecommand and deletecommand. Debugging prompt:
Violation of concurrency : Deletecommand affects 0 of the expected 1 record; or
Violation of concurrency : Updatecommand affects 0 of the expected 1 record.
HereViolation of concurrency: not the concurrency caused by multi-person editing.
Cause:
An exception caused by dataadapter when the number of affected rows is equal to zero during the insert, update, or delete operation.
Possible solutions:
1. check whether there is a primary key.
2 deletecommand: Check whether there is an automatic number field (Access's automatic number field may cause this exception );
Updatecommand: Check whether the original value of the updated field is null (this exception may occur when the original null value is updated ).
3. parallel operations by multiple users may also cause such exceptions.
----------------------
If you use bindingsource and tableadapter, refer to the followingCode:
Bytes -----------------------------------------------------------------------------------
Source of routine: Visual Basic. NET 2005 database programming technology and example published by People's post and telecommunications Publishing House
See: http://www.ptpress.com.cn/books/Book_Information.asp? Bid = 16271
Bytes -----------------------------------------------------------------------------------
Me. Validate ()
Me. Employee basic information bindingsource. endedit ()
Me. Employee basic information tableadapter. Update (Me. Salary Management dataset. Employee basic information. getchanges)
Me. Payroll dataset. Basic employee information. acceptchanges ()
After doing so, the dataset and database are inconsistent. Yes. acceptchanges ()
Statement.
----------------------
The response is as follows:
| ? |
| It should be processed in the rowupdating event. If a row is published and appears, it will be skipped. |
|
We recommend that you handle the problem as follows:
If (this. Salary Management dataset. Basic employee information. getchanges! = NULL)
{Me. Basic employee information tableadapter. Update (Me. Salary Management dataset. Basic employee information. getchanges )}