Solved

Concurrency violation on SQL delete

Posted on 2009-04-06
3
267 Views
Last Modified: 2012-05-06
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
Comment
Question by:mark_norge
3 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 250 total points
ID: 24075001
A "Concurrency violation" means there are 2 rows in the DataTable with the same primary key value. Check your step 1-(B).

Wayne
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 24075119
Consider updating after step 1 to isolate the problem. It would confirm whether the problem is in step 1 or 2.
0
 

Author Closing Comment

by:mark_norge
ID: 31566922
Thanks for the help. I used both suggestions and now use Guids and an additional Update.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Query datatable in LINQ 6 39
VB.net Excel Add-in TaskPane not opening 3 47
Merging PDFs with VB.NET 10 31
Open a word document 23 15
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now