C# -- WinForms "concurrency violation"

Does anyone have a fix for the below ?

 1. user #1 has DataGridView with 1,000+ records
 2. user #1 updates 20 of these records
 3. user #2 deletes one of the 20 records
 4. user #2 COMMITS delete
 5. user #1 COMMITS 20 updates
 6. user #1 gets ERROR
       ** concurrency violation the updatecommand
           affected 0 of the expected 1 records

Attached show my DataSet1.xsd
"GML_PKGCOMPONENTSTableAdapter"
UPDATE and DELETE commands.

Basically I want a way for user #1's 19 updates to
work and get a NOTICE of the 1 failed update
and why it failed.
0001.jpg
0002.jpg
finance_teacherAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
joriszwaenepoelConnect With a Mentor Commented:
I have no sample code available.
Why don't you just try it? Put a breakpoint in your code for the RowUpdated event and examine the EventArgs to find out how to detect is a row was inserted/deleted/updated successfully or which errors occurred.  There is a.Status property and a .Errors property on the EventArgs that you can use for that.
0
 
roeibCommented:
well to make this happen you will need to work in Optimistic Concurrency Style

i recommend you to read this:

http://www.primedigit.com/implementing-optimistic-concurrency-with-sql-timestamps/
0
 
finance_teacherAuthor Commented:
I already use "Optimistic Concurreny Style" (attached),
but this does not prevent the above error on DELETES.

Please help.
0003.jpg
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
joriszwaenepoelCommented:
I think you can force the update to continue when an error occurs by setting its ContinueUpdateOnError property to True.  This makes sure all 19 rows that are not deleted are updated correctly.

Then, you have a RowUpdated event (on the DataAdapter) which you can use to find out, for each row individually, if the update has succeeded or not.
0
 
finance_teacherAuthor Commented:
Please post ContinueUpdateOnError & RowUpdated event sample code.
0
 
finance_teacherAuthor Commented:
Ok, I will retest.
0
All Courses

From novice to tech pro — start learning today.