Use of CancelBatch and telling field changes from deletion

From: Dave Blake (barnswood_at_hotmail.com)
Date: 01/30/05


Date: Sun, 30 Jan 2005 11:41:23 -0000

Using clientside cursors and batchoptimistic locking to make changes to a
number of datasets (on Jet 4 OLE DB). Once the user has made changes locally
and pressed "save" this is my strategy:

All datasets have 'Update Resync' property set to adResyncConflicts;
Post changes
Begin transaction
try
   dataset1 updatebatch
   dataset2 updatebatch
   dataset3 updatebatch
   dataset4 updatebatch ...
   commit transaction
except
   rollback transaction
   Report error to user
end;

If the error is because the underlying data has changed e.g. -2147217864
"Row not located..." then I want the user to have the opportunity to try to
proceed with their update regardless (don't need to report which fields are
different), otherwise I want them to see the current values.

My concerns
a) How do I tell that "Row not located.." is because there is a difference
in non key values, rather than the record having been deleted (or key
changed). When deleted I don't want the user to continue, but maybe be able
to log/print their data.

b) Should I call CancelBatch somewhere? Not sure about this. Would it be
part of showing current values or does requery make it unnecessary?

I'm just trying to think through what happens when say dataset1 update is
successful but dataset2 updatebatch fails because an underlying value has
been changed by someone else. Dataset1 has updates locally applied, so if
the user is allowed to continue with the updates then subsequent changes to
underlying values for dataset1 will not be detected. Can someone sort me out
on this?

Thanks
Dave