By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

Concurrency Violation when programmatically setting cell values in bound DataGridView

P: n/a
RKT
[Background]

I have a DataGridView bound to an MS Access table. This is a single-
user application. When the User is adding or editing a row, the User
may click on a Control elsewhere. That Control has context which I use
to programmatically set *other* r/o cell values for the currently
selected grid row. So, after that click on another control, and
stuffing the related cell values, I want to seamlessly allow the user
to resume editing/adding that row as though its focus was never
interrupted (by the click on the other Control).

This works (out of the box, no special coding) except in the case
where the table is empty such that the selected row being edited is a
*new* row AND the *first* row. In that single case, I get a
"Concurrency Violation: the UpdateCommand affected 0 of the expected 1
records."

I first tried adding what seemed rational approaches such as setting
the row dirty and/or setting Optimistic Locking off on the DataSet and/
or ending the AddNew mode and switching to Edit mode. This quickly
devolved into trying every permutaion of intevening API calls
imaginable to get the row/cell/dataset/etc. into a state that didn't
generate the exception. Every attempt spawns other issues...

[The Question]

Is there a prescribed approach to setting cell values prgrammatically,
particularly for the first row when that row is a new row - where the
exception is thrown?

Sep 27 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.