delphidelphi-2010tclientdatasetmidas-server

Handling update errors in multiple records in the TClientDataset's ReconcileError method


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.


Solution

  • After a bit of debugging and reading I figured out the following: