Concurrency violation (once more...)

  • Thread starter Thread starter Gerard van Dorth
  • Start date Start date
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
 
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/
 
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
 
Got it!
There was a boolean involved which was not initialized (DBNULL) but read
back as FALSE...
That was all, thanks,

Gerard
 
Back
Top