RAD Studio VCL Reference
TDataSet.BeforePost Event

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

property BeforePost: TDataSetNotifyEvent;
__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);
  if DBEdit1.Text = '' then
  DataSet.Fields[2].AsString := DBEdit1.Text;


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!