FetchAll and FetchRows, no effect

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Lu53
Posts: 6
Joined: Fri 25 Jul 2008 23:13

FetchAll and FetchRows, no effect

Post by Lu53 » Fri 21 Dec 2012 00:03

Because the internet connection to the MySQL server is slow, I set FetchAll to False and FetchRows to 25 to speed up data presentation to the user. Unfortunately, it does not work. The application always seems to load ALL data into the DBGrid rather than multiple chunks of 25 each on demand, no matter what I do to FetchAll and FetchRows. Using a TMySQLMonitor, I see only one query being executed (don't know though if multiple should be seen in FetchAll=False mode).
Am I missing the obvious here?
Many thanks
Lu

AndreyZ

Re: FetchAll and FetchRows, no effect

Post by AndreyZ » Fri 21 Dec 2012 09:52

Hello,

Please try using the following code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  con: TMyConnection;
  q: TMyQuery;
begin
  con := TMyConnection.Create(nil);
  q := TMyQuery.Create(nil);
  try
    con.Server := 'server';
    con.Port := 3306;
    con.Username := 'username';
    con.Password := 'password';
    con.Database := 'database';
    con.LoginPrompt := False;
    q.Connection := con;
    q.FetchAll := False;
    q.FetchRows := 25;
    q.SQL.Text := 'select * from bigtable';
    q.Open;
    ShowMessage(IntToStr(q.RecordCount)); // must show 25
  finally
    q.Free;
    con.Free;
  end;
end;
, ahd check that the ShowMessage procedure shows that TMyQuery fetched only 25 records.
Please change this code to demonstrate the problem when TMyQuery fetches all records at once.

Post Reply