DBConcurrencyException (without Concurrency Problems ?)

H

Hans Michael Rupp

I am experimenting with ADO.NET
I use MySQL 3.23 with MyODBC 3.51
At the moment I simply try an insert a select and an update. I use the
usual DataSet approach. The select works and retrieves the data from the
database. When I try an update I always get a
System.Data.DBConcurrencyException

I have looked thru some Microsoft documentation and as far as I
understood it a DBConcurrencyException is only thrown when the DataSet
is out of sync with the database.
I am pretty sure that I don't change the database between the filling of
the DataSet and testing the Update statement. I have already looked at
the DataRow which I try to update immediately before
dataAdapter.Update(dataSetChanged);
it seems hold the same data as as the database.


Does anybody know what could cause this behavior, or give my some hints
what to investigate?

Many thanks,

Hans
 
W

William Ryan eMVP

Hans:

You really need to examine the Update statement's that are being used.
Also, are you using a CommandBuilder , The dataadatperConfiguration wizard
or rolling your own? With Optimistic concurrency every value of each field
must match the original value or your row. With Pessimistic, only the Key
Value needs to match. But it really depends on the update logic and of
course, if anything is changed.

one good way to test it is to create a DB that you know isn't being used by
any other app. you can just script your existing one (and you really only
need to script the tables used in this query and just add some dummy data...
this will at least isolate if the data is changing or not.

Also, do you get the concurrency exception each time? Ultimately the key is
going to be to interrogate the Update statements and see what it's sending
back.


If you post the code it would be a little easier to debug and make sure you
post what the actual Update commands are...use Debug.Writeline or something
to get them so you can paste them into the news reader.


HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top