|
-
Mar 17th, 2009, 07:40 AM
#1
Thread Starter
Member
[2008] DataGridView Update/Concurrency Violation
Hi,
Can someone help me get around the following problem please?
I have an Access database which can be accessed by more than one instance of my application (which is) a Form with a DataGridView on it.
I populate the DGV with
Code:
Form1.Validate()
Form1.CHECKLISTBindingSource.EndEdit()
Form1.CHECKLISTTableAdapter.Update(Form1.chkDataSet.CHECKLIST)
The Access Database can then be updated via the DGV by a button click (which runs the code above (to copy across the latest copy of the DB) and then runs the code below to copy your changes to the DB)
Code:
Form1.CHECKLISTTableAdapter.Fill(Form1.chkDataSet.CHECKLIST)
Form1.DataGridView4.DataSource = Form1.CHECKLISTBindingSource
Form1.DataGridView4.Refresh()
The Access table is basicaly a 'Time' Column and a 'Name' Column.
All instances of the App work well until someone updates a Record (i.e. Name) which has already been updated by someone else.
I then get the following ...
DBConcurrencyException Was unhandled
Concurrency Violation: The UpdateCommand affected 0 of the expected 1 records.
Thanks for any help
D
-
Mar 17th, 2009, 08:05 AM
#2
Re: [2008] DataGridView Update/Concurrency Violation
It's up to you to catch that exception and then ask the user what to do. You need to provide custom code to merge the current user's changes into the database. You can either overwrite the previous changes, discard the current changes or merge the two but, whichever you choose, it's up to you to do it.
-
Mar 17th, 2009, 09:20 AM
#3
Thread Starter
Member
Re: [2008] DataGridView Update/Concurrency Violation
hi jmcilhinney, thanks for the reply.
Do you have any pointers? I'm googling but to no avail and I'm a bit stuck for ideas 
I'd like to just overwrite whatever already is written to the DB and preferably be transparent to the user.
Big thanks!
-
Mar 18th, 2009, 10:30 AM
#4
Thread Starter
Member
Re: [2008] DataGridView Update/Concurrency Violation
Can anyone help here please?
-
Mar 18th, 2009, 01:51 PM
#5
Addicted Member
Re: [2008] DataGridView Update/Concurrency Violation
The following articles within the MSDN library may help you to better understand concurrency violations/exceptions and how to handle them. They have helped me a lot even when the article didn't fit my exact problem, it was my understanding of the methodology that allowed me to adapt and conquer my concurrency feuds.
Furthermore, there will be some problems that you will still require assistance on but most are more willing to help those whom have put forth some effort before asking, and it usually shows in the way you ask.
Reference MSDN Library 2008
Introduction to Data Concurrency in ADO.NET
ms-help://MS.MSDNQTR.v90.en/dv_raddata/html/d5293098-4a88-4110-abd2-34d9e6661664.htm
How to: Handle Concurrency Errors
ms-help://MS.MSDNQTR.v90.en/dv_raddata/html/c1a2d9ce-c567-4103-a04d-969f5b2f5f27.htm
Walkthrough: Handling a Concurrency Exception
ms-help://MS.MSDNQTR.v90.en/dv_raddata/html/73ee9759-0a90-48a9-bf7b-9d6fc17bff93.htm
DBConcurrencyException Class
ms-help://MS.MSDNQTR.v90.en/fxref_system.data/html/85fd7c17-4f5c-bfab-2834-f07b71a7fd8a.htm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|