RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TClientDataSet.BeforePost Event

Occurs before an application posts changes for the active record to the database or change log.

Pascal
property BeforePost: TDataSetNotifyEvent;
C++
__property TDataSetNotifyEvent BeforePost;

Write a BeforePost event handler to take specific action before an application posts dataset changes. BeforePost is triggered when an application calls the Post method. Post checks to make sure all required fields are present, then calls BeforePost before posting the record. 

An application might use BeforePost to perform validity checks on data changes before committing them. If it encountered a validity problem, it could call Abort to cancel the Post operation (Delphi) or throw an exception (C++).  

Delphi Examples: 

 

{
This example checks for a valid entry in a TDBEdit control
and calls the Abort procedure if the control is empty; Abort
cancels the post before it happens.
}
procedure TForm1.ClientDataSet1BeforePost(DataSet: TDataSet);
begin
  if DBEdit1.Text = '' then
    Abort;
  DataSet.Fields[2].AsString := DBEdit1.Text;
end;

 

AfterPost 

Post 

Abort 

Working with Field Component Methods at Runtime

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