[lazarus] TDBGrid question

Jesus Reyes jesusrmx at yahoo.com.mx
Fri May 23 11:48:21 EDT 2003

 --- Michael Van Canneyt <michael.vancanneyt at wisa.be> escribió: > 
> 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.

In fact this is the problem that I have with the scrollbars, the
default scrollbar handling depends of the grid's total width/height
and that depends on rowcount/colcount, by setting this properties
directly you are allowing the default scrollbar handling and
scrollbars works normally, however as Michael wrote this is not
recommended {well actually, I think in some cases a buffered rowset
its s wellcome feature :)} Currently dbgrids only request a number of
buffers that are visually needed. 

I only tested IB components with very small dataset rows so i did't
know if there were problems scrolling, in this matter, I think, one
should play with the dataset scrolling rules if the underlaying
dbengine allows backward/forward scrolling then any grid's request
should succed. Should one trust FDataLink.DataSet.RecordCount for
something? I need investigate further :) .

Jesus Reyes A.

Do You Yahoo!?
La mejor conexión a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx

More information about the Lazarus mailing list