Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Concurrency violation on SQL delete

Hi Experts,
I compare two datatables A (Notes datasource) and B (SQL datasource) the following way:
1. Loop through all rows in A.
(A) If a row with a similar key can be found in B: update the row in B.
(B) If the row can not be found in B, create a new row B.

2. Loop through all rows in B.
(A) If no row with a similar key can be found in can be found in A: delete the row in B.

3. Update B

Datatable A and B should be exactly the same after 1 and 2.

I get a concurrency violation on the delete command "0 rows of 1 were effected" after the update command. Should I update in between 1 and 2 or use accept changes somewere to prevent this message?

Thanks in advance,
MB

0
mark_norge
Asked:
mark_norge
2 Solutions
 
Wayne Taylor (webtubbs)Commented:
A "Concurrency violation" means there are 2 rows in the DataTable with the same primary key value. Check your step 1-(B).

Wayne
0
 
CodeCruiserCommented:
Consider updating after step 1 to isolate the problem. It would confirm whether the problem is in step 1 or 2.
0
 
mark_norgeAuthor Commented:
Thanks for the help. I used both suggestions and now use Guids and an additional Update.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now