Applying Changes

So far the remote database is not changed. All changes are stored on the client side and will be sent to the server only with an explicit call to the ApplyUpdate method on each table that has been changed. Add an ApplyChanges method to fDataModule.

procedure TClientDataModule.ApplyChanges;
begin
  tbl_Tasks.ApplyUpdates;
end;

When to Apply Updates

The right time to apply updates back to the server will depend on what type of application you are developing. You can call ApplyUpdates after every change to a table if you need to, however, it is more efficient to batch changes together before applying them. In this sample application you will achieve that by simply adding an Apply Changes button to the main form and let the user decide when to apply the changes to the server.

Add an Apply Changes Button Task

procedure TClientForm.btnApplyChangesClick(Sender: TObject);
begin
 ClientDataModule.ApplyChanges();
end;