• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • 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,

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).

Consider updating after step 1 to isolate the problem. It would confirm whether the problem is in step 1 or 2.
mark_norgeAuthor Commented:
Thanks for the help. I used both suggestions and now use Guids and an additional Update.
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.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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