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

mark_norgeAsked:
Who is Participating?
 
Wayne Taylor (webtubbs)Connect With a Mentor 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
 
CodeCruiserConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.