Reputation: 6022
I'm trying to use the ReconcileError event to allow the user to correct the data after an update error which occurred in a specific record among others.
Example:
I have a dataset with one field and 3 records, this field have a unique constraint on the database, then I change one value to conflict when it reaches the database, then I call ApplyUpdates on the Dataset.
This will generate an error (violation of unique constraint) in the provider and abort the applyupdates process, returning raAbort in the Action var of the ReconcileError method.
In the ReconcileError method I tryied to use:
Action := HandleReconcileError(aDataSet, UpdateKind, E);
** EDIT **
After debugging and dumping the DataSet records which were returned from the server, I noticed that there are 2 records in this Dataset, the first is the Old record and the second have all the changes I made to the first record.
I'm a bit confused, will I always get this DataSet with 2 records? I thought that it should have only one record with the Old/New values.
Thanks.
Upvotes: 2
Views: 2981
Reputation: 7
In dbExpress you will find with TSQLConnection component, in the parameters an entry, Mars_Connection,which is set to False by default, set this to True and the error message is resolved
Upvotes: 1
Reputation: 6022
After a bit of debugging and reading I figured out the following:
Upvotes: 3
Reputation: 125708
The record passed to OnReconcileError or OnUpdateError is the record that couldn't have updates applied. According to the D2007 help file (note this is a help file link and not a web link!) - note the section regarding the DataSet parameter:
You should always code an OnReconcileError or OnUpdateError event handler, even if only to discard the records returned that could not be applied. The event handlers for these two events work the same way. They include the following parameters:
DataSet: A client dataset that contains the updated record which couldn't be applied. You can use this dataset's methods to get information about the problem record and to edit the record in order to correct any problems. In particular, you will want to use the CurValue, OldValue, and NewValue properties of the fields in the current record to determine the cause of the update problem. However, you must not call any client dataset methods that change the current record in your event handler.
Upvotes: 1