Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-05

... TDBGrid interbase problems ...

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jesus Reyes

Sorry answering after so long time :), and sorry too because i can't link to the original message thread:

Though, I also like the idea of displaying only the data when

needed. But
I

think we need help from you guys as to understanding why is it that

TDBGrid

cannot scroll backwards specially for tables with more 10

records(at least
for

Show quoted text 6 lines
Firebird. ) Regards, Yoyong

Michael appointed after that message that 10 records is probably related to the

Const
  DefaultBufferCount = 10;

defined in dataset.inc

this is right!. Now, TDBgrid actually can do backward/forward scroll. what happen is that TIBQuery "Implementation" explicitly deny this, take a look at the following code in TIBQuery.GetRecord:

...
  if FIsEOF then
    Result := grEOF
  else
  begin
    Result := grOK;
    case GetMode of
    ....
  end;
  if Result = grOK then
  begin
    with PIBBookmark(Buffer + FRecordSize)^ do
    begin
      BookmarkData := FCurrentRecord;
      BookmarkFlag := bfCurrent;
    end;
  end
  else if (Result = grError) then
    DatabaseError('No record');
end;

once TIbQuery reach EOF it can't fetch more records, you have a number a buffers allocated in TDataset (10) beyond this limit TIBQuery can't fetch previous records, so if you reach record 23, you will not be able to backscroll before record 13

TDataset buffer system is a cycled one and in this situation you can see the buffers content cycling in the grid, this could be seen as an error but I don't think it is so.

What can we do to get it working as it is, I'm affraid raising artificially the TDataset.Buffercount by means of DbGrid's FDatalink.Buffercount as Yoyong already done, until TIBQuery implementation gets updated, maybe
FDataLink.BufferCount:=FDataLink.DataSet.RecordCount And updating on trying to get the next record?

I hope this could be useful.

Regards.

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

Reply by email

Unknown author
to Jesus Reyes
Show quoted text 68 lines
Sorry answering after so long time :), and sorry too because i can't link to the original message thread: > > Though, I also like the idea of displaying only the data when needed. But I > think we need help from you guys as to understanding why is it that TDBGrid > cannot scroll backwards specially for tables with more 10 records(at least for > Firebird. ) > > Regards, > > Yoyong > Michael appointed after that message that 10 records is probably related to the Const DefaultBufferCount = 10; defined in dataset.inc this is right!. Now, TDBgrid actually can do backward/forward scroll. what happen is that TIBQuery "Implementation" explicitly deny this, take a look at the following code in TIBQuery.GetRecord: ... if FIsEOF then Result := grEOF else begin Result := grOK; case GetMode of .... end; if Result = grOK then begin with PIBBookmark(Buffer + FRecordSize)^ do begin BookmarkData := FCurrentRecord; BookmarkFlag := bfCurrent; end; end else if (Result = grError) then DatabaseError('No record'); end; once TIbQuery reach EOF it can't fetch more records, you have a number a buffers allocated in TDataset (10) beyond this limit TIBQuery can't fetch previous records, so if you reach record 23, you will not be able to backscroll before record 13 TDataset buffer system is a cycled one and in this situation you can see the buffers content cycling in the grid, this could be seen as an error but I don't think it is so. What can we do to get it working as it is, I'm affraid raising artificially the TDataset.Buffercount by means of DbGrid's FDatalink.Buffercount as Yoyong already done, until TIBQuery implementation gets updated, maybe FDataLink.BufferCount:=FDataLink.DataSet.RecordCount And updating on trying to get the next record?

I don't think this is a good idea. It will blow up your program's memory and be very low, because at each 'Next' all buffers will be reallocated, re-updating the entire grid twice etc. This is not a good solution.

Interbase itself allows only forward scrolling in a result set. This means The TIBQuery class should allocate result buffers by itself as it goes along, keeping all fetched data in memory.

This problem will occur not only in Interbase, but also in other major database engines (mysql is a notable exception) , so it may be a good idea to provide a separate class for this.

Michael.

Reply by email