RAD Studio VCL Reference
TClientDataSet.PacketRecords Property

Indicates the number or type of records in a single data packet.

property PacketRecords: Integer;
__property int PacketRecords;

Use PacketRecords to specify how many records should be contained in a single packet fetched from a provider, or to indicate that the packet returned should contain only metadata. 

When a client dataset is instantiated, PacketRecords is automatically set to -1, meaning that a single packet should contain all records in the dataset. 

If PacketRecords is greater than zero, then it specifies the number of records to return in a packet. 

To retrieve the metadata for a dataset, set PacketRecords to 0. When PacketRecords is zero, the provider returns only information from its dataset that defines the database's structure, such as table, column, constraint, and domain definitions.

Warning: When PacketRecords is greater than 0, the client dataset must fetch its data incrementally. If the provider is on a stateless application server, the client dataset must inform the provider where to start fetching data. This communication can occur using a BeforeGetRecords event handler.

Delphi Examples: 


This example shows how to use the BeforeGetRecords event
handler (a TRemoteEventType value) to send the provider
information it needs for incremental data fetching. Before
fetching the next data packet, the client dataset packages
up the key value of the last record so that the provider
knows where to begin the next data packet. It also sends
some application-specific information, which is stored in
Memo1.  This method is used to pass the sql statement and the
value of the first field for the last record to the server so
that the server can return the correct records. The complete
project using this code example is in
procedure TForm1.ClientDataSet1BeforeGetRecords(Sender: TObject; var OwnerData: OleVariant);
  LastValue: OleVariant;
  CDSClone: TClientDataSet;
  if ClientDataSet1.Active then
    CDSClone := TClientDataSet.Create(Form1);
      CDSClone.CloneCursor(ClientDataSet1, True);
      { turn off FetchOnDemand so that the clone only fetches
        the last LOCAL record }
      CDSClone.FetchOnDemand := False;
      LastValue := CDSClone.Fields[0].AsString;
  end else
    LastValue := NULL;
  OwnerData := VarArrayOf([Memo1.Lines.Text, LastValue]);

procedure TForm1.Button2Click(Sender: TObject);
  ClientDataSet1.PacketRecords := StrToInt(Edit1.Text);


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