DataAdapter and DBConcurrencyException
-
I am trying to put together a quick and dirty app, but have hit a problem and need a litle help!! basically i have a DataAdpter and fill a datatable. This is then bound to a grid, and the user can edit the data (not add or delete records tho) Easy so far! Then they can click save and i call _adapter.Update(_dataTable); now if some of the data has been changed in the database i get an DBConcurrencyException. What i really want to do is prompt the user for each record that has changed by another app in the database, and ask if they want to force their values on the record or abort that record update, and continue with the rest. Can i do this, still using the _adapter.Update method? if not, whats the easyest (sp) way to do it Many Thanks Mark
-
I am trying to put together a quick and dirty app, but have hit a problem and need a litle help!! basically i have a DataAdpter and fill a datatable. This is then bound to a grid, and the user can edit the data (not add or delete records tho) Easy so far! Then they can click save and i call _adapter.Update(_dataTable); now if some of the data has been changed in the database i get an DBConcurrencyException. What i really want to do is prompt the user for each record that has changed by another app in the database, and ask if they want to force their values on the record or abort that record update, and continue with the rest. Can i do this, still using the _adapter.Update method? if not, whats the easyest (sp) way to do it Many Thanks Mark
after some digging, i have found the answer adapter.ContinueUpdateOnError = true; will make sure it continues after an error and SqlCeCommandBuilder builder = new SqlCeCommandBuilder(adapter); builder.ConflictOption = ConflictOption.OverwriteChanges; Makes it a last in wins, which will do for my app.