Datasnap.DBClient.TCustomClientDataSet.ApplyUpdates

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function ApplyUpdates(MaxErrors: Integer): Integer; virtual;

C++

virtual int __fastcall ApplyUpdates(int MaxErrors);

Properties

Type Visibility Source Unit Parent
function public
Datasnap.DBClient.pas
Datasnap.DBClient.hpp
Datasnap.DBClient TCustomClientDataSet

Description

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

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 cannot 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.

See Also

Code Examples