RAD Studio VCL Reference
|
Indicates whether to fetch data packets from the provider on an as-needed basis.
property FetchOnDemand: Boolean;
__property Boolean FetchOnDemand;
By default FetchOnDemand is true, meaning that the client dataset fetches additional packets of data as needed (for example, as a user scrolls through data, or conducts a search). If the provider does not automatically include BLOB fields or nested detail sets in data packets, setting FetchOnDemand to true causes the client dataset to fetch these values when needed as well.
Set FetchOnDemand to false only if your application contains code that explicitly fetches data packets as needed using the GetNextPacket method. Similarly, if FetchOnDemand is false and the provider does not include BLOB data by default (Options includes poFetchBlobsOnDemand), the application must fetch BLOB fields explicitly using the FetchBlobs method. If the provider does not include nested detail sets (Options includes poFetchDetailsOnDemand) and FetchOnDemand is false, the application must fetch nested details explicitly using the FetchDetails method.
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 Demos/DelphiWin32/VCLWin32/MIDAS/Pooler. } procedure TForm1.ClientDataSet1BeforeGetRecords(Sender: TObject; var OwnerData: OleVariant); var LastValue: OleVariant; CDSClone: TClientDataSet; begin if ClientDataSet1.Active then begin CDSClone := TClientDataSet.Create(Form1); try CDSClone.CloneCursor(ClientDataSet1, True); { turn off FetchOnDemand so that the clone only fetches the last LOCAL record } CDSClone.FetchOnDemand := False; CDSClone.Last; LastValue := CDSClone.Fields[0].AsString; CDSClone.Close; finally CDSClone.Free; end; end else LastValue := NULL; OwnerData := VarArrayOf([Memo1.Lines.Text, LastValue]); end; procedure TForm1.Button2Click(Sender: TObject); begin ClientDataSet1.PacketRecords := StrToInt(Edit1.Text); ClientDataSet1.GetNextPacket; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|