[lazarus] TDBGrid question

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri May 23 03:28:01 EDT 2003




On Fri, 23 May 2003 hernan.et at pg.com wrote:

> Hi Jesus,
>
> The scrollbars work for me now just fine. Here is what I did.
>
> I created another TIBQuery, this will just tell me how many records are returned
> based on the SQL passed.  I don't understand why I can't get the number of
> records when using pure sql, e.g.
>
> myIBQry.SQL.Clear;
> myIBQry.SQL.Add('Select * from items');
> myIBQry.Open;
> myIBQry.RecordCount does not work (myIBQuery is of type TIBQuery).

The only way to get the number of records returned by a query,
is to scroll to the last record. IB does not return the number of
records in a result set.

>
> my second query looks like this
>
> myIBSecond.SQL.Clear;
> myIBSecond.SQL.Add('Select count(ID) as NumOfItems from items');
> myIBSecond.Open;
>
> myTDBGrid.RowCount := IntToStr(myIBSecond.Fields[0].AsString); //note no
> AsInteger I don't know why
> myTDBGrid.BufferCount :=  myTDBGrid.RowCount; //this will update

This is VERY bad, it will allocate a HUGE amount of memory when
your query returns a lot of things.

The buffercount of the grid (and dataset) should equal the number of
rows that are displayed on the screen.

Michael.






More information about the Lazarus mailing list