RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomClientDataSet.ApplyUpdates Method

Sends all updated, inserted, and deleted records from the client dataset to the provider for writing to the database.

Pascal
function ApplyUpdates(MaxErrors: Integer): Integer; virtual;
C++
virtual __fastcall int ApplyUpdates(int MaxErrors);

Call ApplyUpdates to write all updated, inserted, and deleted records from the client dataset to the database or source dataset. MaxErrors indicates the maximum number of errors that the provider should allow before prematurely stopping the update operation. Set MaxErrors to –1 to indicate that there is no limit to the number of errors. 

ApplyUpdates  

1.Generates a BeforeApplyUpdates event. (This event may not be public on some TCustomClientDataSet descendants.) 

2.Calls the provider to apply the updates in the Delta property and receives any records returned by the provider because they generated errors when it attempted to apply them to the database. 

3.Generates an AfterApplyUpdates event. (This event may not be public on some TCustomClientDataSet descendants.) 

4.Calls the client dataset's Reconcile method to reconcile any records that are returned in step 2.

Warning: The provider can't detect when an update conflicts with another user's changes to a memo field. The server will not detect and return these conflicts as errors.
ApplyUpdates returns the number of errors it encountered. Based on this return value and the setting of MaxErrors, successfully applied records are removed from the client dataset's change log. If the update process is aborted before all updates are applied, any unapplied updates remain in the change log.  

Delphi Examples: 

 

{
This BeforeDisconnect event handler makes sure that the
client dataset has applied all its pending updates before
terminating the connection to the server.
}
procedure TForm1.RemoteServer1BeforeDisconnect(Sender: TObject);
begin
  if (ClientDataSet1.ChangeCount > 0) then 
    ClientDataSet1.ApplyUpdates(-1);
end;

 

Reconcile 

AS_ApplyUpdates 

BeforeApplyUpdates 

AfterApplyUpdates 

Delta 

Applying Updates 

Setting Up a Simple Dataset 

Using the BDE to Cache Updates 

Connecting a Client Dataset to Another Dataset in the Same Application 

Communicating with the Client Dataset 

Updating Data in dbExpress Applications

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!