RAD Studio VCL Reference
|
Implements a virtual method to write a modified record to the database or change log.
procedure Post; virtual;
virtual __fastcall Post();
TDataSet implements a virtual method to write a modified record to the database or change log. Dataset methods that change the dataset state, such as Edit, Insert, or Append, or that move from one record to another, such as First, Last, Next, and Prior automatically call Post.
Different types of datasets handle posting differently:
BDE-enabled datasets post records directly to the database server unless CachedUpdates is true. When caching updates, BDE-enabled datasets post records to an internal change log until they are applied to the database by calling ApplyUpdates.
ADO and InterBaseExpress datasets post records directly to the database server.
Client datasets post records to an internal change log until they are applied to the database by calling ApplyUpdates or merged with the client dataset's data by calling MergeChangeLog.
Unidirectional datasets are read-only and do not post records at all.
Designers of custom datasets can choose whether to implement Post by writing records to the database server or to an internal change log.
Delphi Examples:
{ This example appends a new record to a table or client dataset when the user clicks a button. The two fields Field1 and Field2 are filled from the contents of two edit controls. This example requires a populated TTable or TDataSet with the appropriate field values. } procedure TForm1.Button1Click(Sender: TObject); begin Customers.Append; Customers.FieldValues['Field1'] := StrToInt(Edit1.text); Customers.FieldValues['Field2'] := Edit2.text; Customers.Post; end;
{ The following fragment prompts the user to confirm changes to a record; if the user clicks Yes, the record is posted to the table, otherwise the changes are cancelled. } procedure TForm1.Button2Click(Sender: TObject); begin if MessageDlg('Update Record?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then Table1.Post else Table1.Cancel; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|