RAD Studio VCL Reference
|
Occurs before the provider creates a data packet and sends it to a client dataset.
property BeforeGetRecords: TRemoteEvent;
__property TRemoteEvent BeforeGetRecords;
Write a BeforeGetRecords event handler to respond to custom information from a client dataset. BeforeGetRecords is part of the mechanism by which a provider and a client dataset communicate information about data fetching. When the provider is part of a stateless application server, this mechanism allows the provider and the client dataset to communicate persistent state information.
When the client dataset fetches data from the provider, the following events occur:
1.The client dataset receives a BeforeGetRecords event, where it can encode custom information into an OleVariant.
2.The provider receives a BeforeGetRecords event, where the OleVariant from the client dataset appears as the OwnerData parameter. The provider can respond to or change that information before it creates a data packet.
3.The provider generates the data packet.
4.The provider receives an AfterGetRecords event, where it can encode custom information into its OwnerData parameter or respond to information from the BeforeGetRecords event handler.
5.The client dataset receives an AfterGetRecords event, where it can respond to the custom information returned by the provider in its AfterGetRecords event handler.
Delphi Examples:
{ This example shows the implementation of a provider BeforeGetRecords event handler and a RemoteDataModule UpdateRegistry method. The complete project using this code example is in Demos/DelphiWin32/VCLWin32/MIDAS/Pooler. } procedure TPooledRDM.DataSetProvider1BeforeGetRecords(Sender: TObject; var OwnerData: OleVariant); begin try Query1.Close; Query1.SQL.Text := OwnerData[0]; if not VarIsNull(OwnerData[1]) and not VarIsEmpty(OwnerData[1]) then begin Query1.Open; if not Query1.Locate(Query1.Fields[0].FieldName, OwnerData[1], []) then raise Exception.Create('Record not found'); Query1.Next; end; finally OwnerData := NULL; end; end;
Communicating with the Client Dataset
Responding to Client Data Requests
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|