it should still fix some issue If you mean the database table, that's exactly how ApplyUpdates is supposed to work. Are you using MIDAS or cached updates? In the former case data are stored in the in-memory cache of TClientDataset, and can be accessed on the client side using TClientDataset methods (i.e. reading UpdateStatus, or setting StatusFilter) or accessing directly the Delta property. If you're using BDE cached updates, changes are stored AFAIK in some local temporary tables the BDE creates. You can still use UpdateStatus or UpdateRecordType to check for changes to records. In both situations, you have no way to see changes outside the client until they are applied - until then they exist only in the client local cache.
TClientDataset ApplyUpdates error because of database table constraint
To fix this issue I think you may try to implement the OnReconcileError event which is being fired once for each record that could not be applied to the dataset. So I would try the following code, raSkip means here to skip the current record:
procedure TForm1.ClientDataSet1ReconcileError(DataSet: TCustomClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind; var Action: TReconcileAction);
Action := raSkip;
ShowMessage('The record with ID = ' + DataSet.FieldByName('ID').AsString +
' couldn''t be updated!' + sLineBreak + E.Context);
TClientDataset.ApplyUpdates fails with 'SQL not supported' when using SQLDirect components
I wish this help you I ran into this problem recently on a quick project I rustled up without the precaution of setting an OnReconcileError handler, as queried by @mjn. Once I'd set up the OnReconcileError handler, it was obvious that the problem was that the provider's TSqlResolver wasn't able to identify the row to update. Iirc, the message on the ReconcileError pop-up form was words to the effect of "Unable to locate record. No key specified."
CDS1.Fields.ProviderFlags := [pfInKey];
Does TClientDataSet.ApplyUpdates(0) require to execute CheckBrowseMode/Post before?
I hope this helps you . I have TIBQuery-TDataSetProvider-TClientDataSet chain in Delphi 2009 (Firebird 3.0) and I execute MyClientDataSet.ApplyUpdates(0). Am I required to call CheckBrowseMode or Post on this CDS before calling ApplyUpdates(0). I am almost sure that I am required to call Post/CheckBrowseMode and I think that no-posted updates will not be applied to the IBQuery, I have no documentation for/against such thinking but it is logical to think so. But sometimes I can observe that MyClientDataSet is in [dsInsert, dsEdit] state before ApplyUpdates(0) and the new values are still posted and saved in query. But there are evidence and reason against that as well. So - I am confused. , or is it rule that I can find in the documentation?
function TCustomClientDataSet.ApplyUpdates(MaxErrors: Integer): Integer;
RootDataset := Self;
while RootDataset.FParentDataSet <> nil do
RootDataset := RootDataset.FParentDataset;
with RootDataset do
if ChangeCount = 0 then
Result := 0 else
Reconcile(DoApplyUpdates(Delta, MaxErrors, Result));