Concurrency violation (once more...)

G

Gerard van Dorth

Hi,

Got a databound DataGrid,
add a record, update the undelaying database (single user/single session),
make a change on de newly created record
try to update: error "Concurrency Violation"

In samples I saw the DataGrid binds the data again after an update
in ths WinAppl I don't want the re-bind (takes too long).

Why do I get the "Concurrency Violation" and how to prevent it withou a
re-bind?

The update code is straight-forward:

dim da as OleDataAdaptor = new OleDataAdaptor(theSelect, theConnect)
dim cmdBld as OleCommandBuilder = new OleCommandBuilder(da)
da.Update(theDataSet, theTable) // One of the 2 tables involved

Thanks in avdance for any help,
Gerard
 
W

William Ryan eMVP

CommandBuilders have really lame support for concurrency. Make sure that
you have ended the current edit and that no other fields have changed.
Remember that with CB's they check every single field of the record, not
just the keys. Also, check what command is being used to send back to the
DB and verify those values. You can also trap onRowUpdated and for
instance, check if the Row.RowError = "Optimistic concurrency violation
deteced" and if it does, go with set the .Status to SkipCurrentRow. There's
a lot you can do if to notify the user and give them some choices but that's
a whole different issue.

--

W.G. Ryan, eMVP

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

Marina

Sounds like you need to turn option strict on.

Gerard van Dorth said:
Got it!
There was a boolean involved which was not initialized (DBNULL) but read
back as FALSE...
That was all, thanks,

Gerard
 
G

Gerard van Dorth

Got it!
There was a boolean involved which was not initialized (DBNULL) but read
back as FALSE...
That was all, thanks,

Gerard
 

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