Page 1 of 1

Preload data

Posted: Tue 19 Jun 2012 17:02
by geanni
Hi,

I have a grid connected to a ClientDataSet. Everything works fine till the amount of data to be displayed increase. In case we have 40000 rows it becomes very slow. Is there any possibility to preload (paginate) somehow automatically the loading of data?

Geanni

Re: Preload data

Posted: Wed 20 Jun 2012 07:25
by AndreyZ
Hello,

To solve the problem, you should set the FetchAll property to False. Here is a code example:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyQuery1.FetchAll := False;
  MyQuery1.FetchRows := 25;
  DataSetProvider1.DataSet := MyQuery1;
  ClientDataSet1.SetProvider(DataSetProvider1);
  ClientDataSet1.PacketRecords := 25;
  ClientDataSet1.Open;
end;
In this case data will be fetched by 25 records when it is explicitly requested.