update concurrency exception

pete_484

New member
Joined
Feb 6, 2007
Messages
3
Programming Experience
1-3
Hi, I am having a problem with my VB .NET application. I am trying to do the most simplest of things, and I've even achieved this task before.

All I am trying to do is update an access DB from VB .NET 2003 using OleDb. I have dragged a data adapter onto my form and configured it correctly setting the connection to the DB and setting a query for the adapter to just read in all columns from a single table. I have then generated a data set from the data adapter. I have placed a datagrid on my form to hold the data from the dataset.

For the load event on the form I declare the code...

VB.NET:
Me.updateAdapter.Fill(Me.updateDS)
This works fine, and it fills the dataset, which is displayed by the datagrid...

I have then added an update button to the form so that if the datagrid is edited the dataset (& DB) are updated accordingly. The code I use for the click event of the button is...

VB.NET:
Me.updateAdapter.Update(Me.updateDS)
However I am getting a concurrency exception. I cannot believe it wont work as I usually like to hard code everything, but it wont even work using the graphical way.

Can anyone please explain to me how I might solve this, or why it is happening?

Most of the comments I have seen about concurrency exceptions say they are not thrown even to do with issues of actual concurrency...

the exception I catch for it say...

VB.NET:
System.Data.DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 records.
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
Any help would be much appreciated thanks.
 
Don't double-post. Thank you. All the duplicates were deleted.
 
Your problem here is the crappy MS wizard has gone and over-done it whilst creating the UPDATE query. Chances are that it hasn't used optimistic concurrency which would help to reduce the likelihood of update confilcts. This is why i like to write all my own SQL. Post the update command text and lets take a look.
 
Back
Top