Sign in Join

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

Mailing lists / lazarus / 2003-05

TDBGrid question

20 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

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

Michael Van Canneyt
to Jeroen van Iddekinge: If I simulate what ShiftBuffersUp and ShiftBufferDown do, I think thats wrong First what…
Jeroen van Iddekinge wrote 35 lines
Hi, If I simulate what ShiftBuffersUp and ShiftBufferDown do, I think thats wrong First what shiftbuffersup does: For example Buffer: 0123456 (numbers ar original content of buffer before call to shift buffersup ) procedure is called with the following: Offset=2 Distance=3 Buffercount=7: FirstMove move1: "Move(FBuffers[Offset],Temp^,MoveSize);" Temp=234 (temp containts the old buffer 2,3 and 4) buffer=unchanged move2: Move(FBuffers[Offset+Distance],FBuffers[Offset], (FBufferCount-Distance-Offset)*SizeOf(Pchar)); =5 =2 (2)*sizeof() Temp=unchanged buffer=01563456 move3: Move(Temp^,FBuffers[FBufferCount-Distance-Offset],MoveSize); 2 (3)*sizeof temp=unchanged buffer=0123456 <==final. If i look at the result i find it verry strange... So far as I understand what procedure ShiftBuffersDown does, it rotate all the buffers. Thats compleetly different what ShiftBuffersUp does. For rotation you don't need an offset parameter, so why does ShiftBuffers have a 'offset' parameter?

The 'offset' is used to make a gap:

[ABCDEFGHIJK]

[ABC DEFGHIJ]

This is needed when doing an insert The insert needs to create a new buffer at the current location (which is the 'offset'). see line 1043:

   ShiftBuffers(1,FActiveRecord);

But I agree the implementation is messy.
I wanted to have the buffer management in 1 routine; For clarity it may be needed to split it out in 2 routines, where 1 does simple rotation (forward/backward) and the second makes the gap for the new record.

Feel free to have a go at it :-)

Michael.

Reply by email

Jeroen van Iddekinge

Hi,

If I simulate what ShiftBuffersUp and ShiftBufferDown do, I think thats wrong

First what shiftbuffersup does:

For example
Buffer: 0123456 (numbers ar original content of buffer before call to shift buffersup ) procedure is called with the following:
Offset=2
Distance=3
Buffercount=7:
FirstMove
move1:
"Move(FBuffers[Offset],Temp^,MoveSize);"
Temp=234 (temp containts the old buffer 2,3 and 4) buffer=unchanged

move2:
Move(FBuffers[Offset+Distance],FBuffers[Offset],

     (FBufferCount-Distance-Offset)*SizeOf(Pchar));
               =5                        =2          (2)*sizeof()
      Temp=unchanged
       buffer=01563456

move3:

   Move(Temp^,FBuffers[FBufferCount-Distance-Offset],MoveSize);
                         2                             (3)*sizeof
   temp=unchanged
   buffer=0123456 <==final.

If i look at the result i find it verry strange...

So far as I understand what procedure ShiftBuffersDown does, it rotate all the buffers. Thats compleetly different what ShiftBuffersUp does. For rotation you don't need an offset parameter, so why does ShiftBuffers have a 'offset' parameter?

Greez,

jeroen van Iddekinge

Earlier message 39 lines
--------- Original Message --------- DATE: Mon, 19 May 2003 10:55:53 From: Michael Van Canneyt To: Cc: > > >On Mon, 19 May 2003 wrote: > >> >> >> Hi Jesus, >> >> I have tried using TDBGrid and it work quite well. But I noticed that I cannot >> scroll backward when my table contains more than 10, (my table contains 56 >> rows). I have tried to track it down and it seems that the problem is somewhere >> in TDataset or its parent(s). Can someone have a look on this? > >I've had this issue in the past, and I suspect has something to do with the buffer >scrolling. I have not yet been able to pinpoint the exact error, however. > >The procedure you want is in dataset.inc, line 1634 > >Procedure TDataset.ShiftBuffers (Offset, Distance : longint); > >Subprocedure 'shiftbuffersdown'. > >I currently do not have enough time to look at it, but if someone else >has, the above info may help to pinpoint the exact problem. > >Michael. > >_________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives >

Reply by email

Michael Van Canneyt
to Unknown author: I have tried using TDBGrid and it work quite well. But I noticed that I cannot scroll…
Show quoted text 8 lines
Hi Jesus, I have tried using TDBGrid and it work quite well. But I noticed that I cannot scroll backward when my table contains more than 10, (my table contains 56 rows). I have tried to track it down and it seems that the problem is somewhere in TDataset or its parent(s). Can someone have a look on this?

I've had this issue in the past, and I suspect has something to do with the buffer scrolling. I have not yet been able to pinpoint the exact error, however.

The procedure you want is in dataset.inc, line 1634

Procedure TDataset.ShiftBuffers (Offset, Distance : longint);

Subprocedure 'shiftbuffersdown'.

I currently do not have enough time to look at it, but if someone else has, the above info may help to pinpoint the exact problem.

Michael.

Reply by email

Unknown author

Hi Jesus,

I have tried using TDBGrid and it work quite well. But I noticed that I cannot scroll backward when my table contains more than 10, (my table contains 56 rows). I have tried to track it down and it seems that the problem is somewhere in TDataset or its parent(s). Can someone have a look on this?

Regards,

Yoyong

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Jesus Reyes on 05/08/2003 07:53 PM GMT

Jesus Reyes To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: [lazarus]

05/09/2003 03:53 AM
Please respond to

hi, here is a patch for grids.pas. It allows autoedit (edit without press F2), also here is a link for dbgrids, sorry I said that i will do a component but I have been very busy, maybe the next time :) http://mx.geocities.com/jesusrmx/lazarus/dbgrid_dist_2.tar.gz , I will send to Michael a patch for fcl/db, but its included in the archive.

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

(ReplyTextOnly removed attachment: lazpatch.diff.gz)

Reply by email

Jesus Reyes
to Michael Van Canneyt: I've had this issue in the past, and I suspect has something to do with the buffer…

--- Michael Van Canneyt escribi�: >

Show quoted text 32 lines
On Mon, 19 May 2003 wrote: > > > Hi Jesus, > > I have tried using TDBGrid and it work quite well. But I noticed that I cannot > scroll backward when my table contains more than 10, (my table contains 56 > rows). I have tried to track it down and it seems that the problem is somewhere > in TDataset or its parent(s). Can someone have a look on this? I've had this issue in the past, and I suspect has something to do with the buffer scrolling. I have not yet been able to pinpoint the exact error, however. The procedure you want is in dataset.inc, line 1634 Procedure TDataset.ShiftBuffers (Offset, Distance : longint); Subprocedure 'shiftbuffersdown'. I currently do not have enough time to look at it, but if someone else has, the above info may help to pinpoint the exact problem. Michael.

Sorry, I missed the original message from Yoyong. Still I can't reproduce the problem, I have a dataset with hundreds of rows and i can go forward/backward without problem. Can you give more details about dbgrid geometry/dataset derivative, a backtrace?

Thanks.

Jesus Reyes

_________________________________________________________ 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

Hi Jesus,

Here is what I have done inorder for me to work with TDBGrid.

I added/created a property named BufferCount in TDBGrid class

property BufferCount : Integer Read FBufferCount Write SetBufferCount;
procedure TCustomDBGrid.SetBufferCount(const Count : Integer);
begin
     FBufferCount := count;
     if Count > RowCount then
          FDataLink.BufferCount := count
     else
          FDataLink.BufferCount := RowCount;
end;

I changed UpdateBufferCount to

procedure TCustomDBGrid.UpdateBufferCount;
begin
     if BufferCount <= RowCount then
          FDataLink.BufferCount := RowCount + 1
     else
          FDataLink.BufferCount := BufferCount;//buffer count of this class
end;

The reason I did this was that I discovered when I set FDataLink.BufferCount to more than my table's number of records, I can scroll the TDBGrid fine.

Hope you can validate if this work around is correct.

Regards,

Yoyong Hernan

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Jesus Reyes on 05/19/2003 05:19 PM GMT

Jesus Reyes To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] TDBGrid question

05/20/2003 01:19 AM
Please respond to

--- Michael Van Canneyt escribi�: >

Show quoted text 32 lines
On Mon, 19 May 2003 wrote: > > > Hi Jesus, > > I have tried using TDBGrid and it work quite well. But I noticed that I cannot > scroll backward when my table contains more than 10, (my table contains 56 > rows). I have tried to track it down and it seems that the problem is somewhere > in TDataset or its parent(s). Can someone have a look on this? I've had this issue in the past, and I suspect has something to do with the buffer scrolling. I have not yet been able to pinpoint the exact error, however. The procedure you want is in dataset.inc, line 1634 Procedure TDataset.ShiftBuffers (Offset, Distance : longint); Subprocedure 'shiftbuffersdown'. I currently do not have enough time to look at it, but if someone else has, the above info may help to pinpoint the exact problem. Michael.

Sorry, I missed the original message from Yoyong. Still I can't reproduce the problem, I have a dataset with hundreds of rows and i can go forward/backward without problem. Can you give more details about dbgrid geometry/dataset derivative, a backtrace?

Thanks.

Jesus Reyes

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

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Mattias Gaertner
to Unknown author
Show quoted text 7 lines
I thought that I corrected those details, later I will try to verify this, thanks. Meanwhile feel free to do any changes later if you like we can insert them, I wanted to get the scrollbars working but for the moment I cant, I tried to do a package with the new package system and I detected some painting problems while in form designing,

There is a problem with non visual components. When the form move or some gtk internal layout widgets resize the coordinates are not always correct and the icons are not properly moved.

Show quoted text 5 lines
I packaged a TMySQLDataset component and for the first time a see the grid filling a design time !. Unfortunatelly TDataSet derivatives seems to have problems at the form streaming time :(. I'm not in the office so I cant post the backtraces but it seem its a RTTI issue.

Is this a new bug or the one found last week?

Mattias

Reply by email

Michael Van Canneyt
to Unknown author: The scrollbars work for me now just fine. Here is what I did. I created another TIBQuery,…
Show quoted text 12 lines
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.

Show quoted text 10 lines
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.

Reply by email

Jesus Reyes
to Mattias Gaertner: On Thu, 22 May 2003 19:43:18 -0600 There is a problem with non visual components. When…

--- Mattias Gaertner escribi�: > On Thu,
22 May 2003 19:43:18 -0600

Show quoted text 20 lines
"Jesus Reyes" wrote: > I thought that I corrected those details, later I will try to verify this, > thanks. > > Meanwhile feel free to do any changes later if you like we can insert > them, I wanted to get the scrollbars working but for the moment I cant, I > tried to do a package with the new package system and I detected some > painting problems while in form designing, There is a problem with non visual components. When the form move or some gtk internal layout widgets resize the coordinates are not always correct and the icons are not properly moved.

Oh, in fact i was talking of dbgrids painting at design time and specifically when the dbgrid has some content to show, I can see the proble you describe, that little shaking icons I thought it was an animation effect ;)

Show quoted text 15 lines
> I packaged a TMySQLDataset component and > for the first time a see the grid filling a design time !. Unfortunatelly > TDataSet derivatives seems to have problems at the form streaming time :(. > I'm not in the office so I cant post the backtraces but it seem its a RTTI > issue. Is this a new bug or the one found last week? Mattias

Maybe i should update my sources, my last update was when one propery (database?) duplicate was corrected

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

Hi all,

It was indeed not a very good decision to determine ahead of time the number of records for the TDBGrid, as was pointed out by Marc. But I am also thinking how the grids are being designed by "SAP Gui systems". Wherein there is a set limit of 9999 in SAP 4.6D. I don't know if you guys buy out that we set a limit for DBGrids .. et al... in the same way that SAP grids are designed (at least, based on my understanding).

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

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Jesus Reyes on 05/23/2003 04:19 PM GMT

Jesus Reyes To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] TDBGrid question

05/24/2003 12:19 AM
Please respond to

--- Mattias Gaertner escribi�: > On Thu,
22 May 2003 19:43:18 -0600

Show quoted text 20 lines
"Jesus Reyes" wrote: > I thought that I corrected those details, later I will try to verify this, > thanks. > > Meanwhile feel free to do any changes later if you like we can insert > them, I wanted to get the scrollbars working but for the moment I cant, I > tried to do a package with the new package system and I detected some > painting problems while in form designing, There is a problem with non visual components. When the form move or some gtk internal layout widgets resize the coordinates are not always correct and the icons are not properly moved.

Oh, in fact i was talking of dbgrids painting at design time and specifically when the dbgrid has some content to show, I can see the proble you describe, that little shaking icons I thought it was an animation effect ;)

Show quoted text 15 lines
> I packaged a TMySQLDataset component and > for the first time a see the grid filling a design time !. Unfortunatelly > TDataSet derivatives seems to have problems at the form streaming time :(. > I'm not in the office so I cant post the backtraces but it seem its a RTTI > issue. Is this a new bug or the one found last week? Mattias

Maybe i should update my sources, my last update was when one propery (database?) duplicate was corrected

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

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Jesus Reyes
to Unknown author: Here is what I have done inorder for me to work with TDBGrid. I added/created a property…

I thought that I corrected those details, later I will try to verify this, thanks.

Meanwhile feel free to do any changes later if you like we can insert them, I wanted to get the scrollbars working but for the moment I cant, I tried to do a package with the new package system and I detected some painting problems while in form designing, I packaged a TMySQLDataset component and for the first time a see the grid filling a design time !. Unfortunatelly TDataSet derivatives seems to have problems at the form streaming time :(. I'm not in the office so I cant post the backtraces but it seem its a RTTI issue.

regards.

Jesus Reyes A.

Earlier message 130 lines
----- Original Message ----- From: To: Sent: Thursday, May 22, 2003 5:14 PM Subject: Re: [lazarus] TDBGrid question > Hi Jesus, > > Here is what I have done inorder for me to work with TDBGrid. > > I added/created a property named BufferCount in TDBGrid class > > property BufferCount : Integer Read FBufferCount Write SetBufferCount; > > procedure TCustomDBGrid.SetBufferCount(const Count : Integer); > begin > FBufferCount := count; > if Count > RowCount then > FDataLink.BufferCount := count > else > FDataLink.BufferCount := RowCount; > end; > > I changed UpdateBufferCount to > > procedure TCustomDBGrid.UpdateBufferCount; > begin > if BufferCount <= RowCount then > FDataLink.BufferCount := RowCount + 1 > else > FDataLink.BufferCount := BufferCount;//buffer count of this class > > end; > > The reason I did this was that I discovered when I set FDataLink.BufferCount to more than my table's number of records, I can scroll the TDBGrid fine. > > Hope you can validate if this work around is correct. > > Regards, > > Yoyong Hernan > > > > > Internet Mail Message > Received from host: > svcr-216-37-230-2.dsl.svcr.epix.net > [216.37.230.2] > > > > From: Jesus Reyes on 05/19/2003 05:19 PM GMT > > Jesus Reyes To: > Cc: (bcc: Yoyong Hernan-ET/PGI) > Subject: Re: [lazarus] TDBGrid question > > 05/20/2003 01:19 AM > Please respond to > > > > > > > > --- Michael Van Canneyt escribi�: > > > > > On Mon, 19 May 2003 wrote: > > > > > > > > > > > Hi Jesus, > > > > > > I have tried using TDBGrid and it work quite well. But I noticed > > that I cannot > > > scroll backward when my table contains more than 10, (my table > > contains 56 > > > rows). I have tried to track it down and it seems that the > > problem is somewhere > > > in TDataset or its parent(s). Can someone have a look on this? > > > > I've had this issue in the past, and I suspect has something to do > > with the buffer > > scrolling. I have not yet been able to pinpoint the exact error, > > however. > > > > The procedure you want is in dataset.inc, line 1634 > > > > Procedure TDataset.ShiftBuffers (Offset, Distance : longint); > > > > Subprocedure 'shiftbuffersdown'. > > > > I currently do not have enough time to look at it, but if someone > > else > > has, the above info may help to pinpoint the exact problem. > > > > Michael. > > > > > Sorry, I missed the original message from Yoyong. Still I can't > reproduce the problem, I have a dataset with hundreds of rows and i > can go forward/backward without problem. Can you give more details > about dbgrid geometry/dataset derivative, a backtrace? > > Thanks. > > Jesus Reyes > > _________________________________________________________ > Do You Yahoo!? > La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. > http://net.yahoo.com.mx > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives > > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Michael Van Canneyt
to Jesus Reyes: --- Michael Van Canneyt escribi�: > In fact this is the problem that I have with the…
Show quoted text 54 lines
--- Michael Van Canneyt escribi�: > > > On Fri, 23 May 2003 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.

This is the correct behaviour. If you look at a DBGrid in Delphi, you will notice that it's scrollbar doesn't work 'normal'; it only supports paging forward and backward, the position of the thumb is usually in the middle of the grid; exactly because the grid doesn't know how many rows there actually are.

Show quoted text 7 lines
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 :) .

The 'recordcount' should under no circumstance be trusted. It may change as you navigate through the records. Check out IBDAtaset from IBX: the recordcoount is initially 1, and is updated as you scroll through the dataset. To get the correct recordcount, one must do a 'last', obtain the recordcount, and then do a 'first' again. This possibly will fetch all data _twice_ so it is not recommended.

On the other hand, MySQL does return a correct recordcount which can be used even without navigating through all records.

Michael.

Reply by email

Marc Weustink
to Michael Van Canneyt: The only way to get the number of records returned by a query, is to scroll to the last…

+ From: Behalf Of
+
+ On Fri, 23 May 2003 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.

Indeed, you don't want all that. When working with databases, cursors, and transactions, there is no one who can garantee that your second query returns the same amount of rows as the first.

Example (based on Oracle, don't know much internal aboput other DBs)

User1: starts a transaction and adds/removes a lot of rows. User2: runs your example part1, creating a cursor to fetch the records User1: commits his/her changes
User2: hits your example part2, creating a cursor to fetch the count now the number rows is different.

In general, when working with multiuser environments, you never ever even want to think about using such constructions.

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

Marc

Reply by email

Michael Van Canneyt
to Unknown author: It was indeed not a very good decision to determine ahead of time the number of records…
Show quoted text 8 lines
Hi all, It was indeed not a very good decision to determine ahead of time the number of records for the TDBGrid, as was pointed out by Marc. But I am also thinking how the grids are being designed by "SAP Gui systems". Wherein there is a set limit of 9999 in SAP 4.6D. I don't know if you guys buy out that we set a limit for DBGrids .. et al... in the same way that SAP grids are designed (at least, based on my understanding).

No, there should be no limit. You don't need this. Grids work fine in Delphi without limits.

Show quoted text 5 lines
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. )

It has probably still to do with the buffer handling. I think there might be still an error in that: 10 is the default buffer size, this is not a coincidence.

Michael.

Reply by email

Jesus Reyes
to Michael Van Canneyt: The only way to get the number of records returned by a query, is to scroll to the last…

--- Michael Van Canneyt escribi�: >

Show quoted text 44 lines
On Fri, 23 May 2003 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

Reply by email

Michael Van Canneyt
to Unknown author: Here is what I have done inorder for me to work with TDBGrid. I added/created a property…
Show quoted text 31 lines
Hi Jesus, Here is what I have done inorder for me to work with TDBGrid. I added/created a property named BufferCount in TDBGrid class property BufferCount : Integer Read FBufferCount Write SetBufferCount; procedure TCustomDBGrid.SetBufferCount(const Count : Integer); begin FBufferCount := count; if Count > RowCount then FDataLink.BufferCount := count else FDataLink.BufferCount := RowCount; end; I changed UpdateBufferCount to procedure TCustomDBGrid.UpdateBufferCount; begin if BufferCount <= RowCount then FDataLink.BufferCount := RowCount + 1 else FDataLink.BufferCount := BufferCount;//buffer count of this class end; The reason I did this was that I discovered when I set FDataLink.BufferCount to more than my table's number of records, I can scroll the TDBGrid fine. Hope you can validate if this work around is correct.

It is definitely correct in the sense that this must be done for a grid to work correctly.

Michael.

Reply by email

Unknown author

Hi all,

To give more details, I am using Firebird 1.0.2 under Linux of course.

To Jesus,

The message below was my original post. I think this has to do also with TIBQuery, do I am not really sure. If I may ask, what database are using for testing TDBGrid?

Regards,

Yoyong

>>Hi Jesus, >>I have tried using TDBGrid and it work quite well. But I noticed that I

cannot scroll backward when my table contains more than 10, (my table contains 56 rows). I >>>have tried to track it down and it seems that the problem is somewhere in TDataset or its parent(s). Can someone have a look on this?

>>Regards, >>Yoyong

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Jesus Reyes on 05/19/2003 05:19 PM GMT

Jesus Reyes To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] TDBGrid question

05/20/2003 01:19 AM
Please respond to

--- Michael Van Canneyt escribi�: >

Show quoted text 32 lines
On Mon, 19 May 2003 wrote: > > > Hi Jesus, > > I have tried using TDBGrid and it work quite well. But I noticed that I cannot > scroll backward when my table contains more than 10, (my table contains 56 > rows). I have tried to track it down and it seems that the problem is somewhere > in TDataset or its parent(s). Can someone have a look on this? I've had this issue in the past, and I suspect has something to do with the buffer scrolling. I have not yet been able to pinpoint the exact error, however. The procedure you want is in dataset.inc, line 1634 Procedure TDataset.ShiftBuffers (Offset, Distance : longint); Subprocedure 'shiftbuffersdown'. I currently do not have enough time to look at it, but if someone else has, the above info may help to pinpoint the exact problem. Michael.

Sorry, I missed the original message from Yoyong. Still I can't reproduce the problem, I have a dataset with hundreds of rows and i can go forward/backward without problem. Can you give more details about dbgrid geometry/dataset derivative, a backtrace?

Thanks.

Jesus Reyes

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

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Unknown author

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).

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
FDataLink.BufferCount --> note my message below
myTDBGrid.ColCount := 8;// this can be determined in advanced.

About the streaming, I have the same problem before. One of the guru's around just redeclared all properties in your final class in the published section. If you have an archive look at TIBDatabase,TIBQuery and its decendants and compare that with the current source code.

Regards,

Yoyong Hernan

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: "Jesus Reyes" on 05/23/2003 01:43 AM GMT

"Jesus Reyes" To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: RE: [lazarus] TDBGrid question

05/23/2003 09:43 AM
Please respond to

I thought that I corrected those details, later I will try to verify this, thanks.

Meanwhile feel free to do any changes later if you like we can insert them, I wanted to get the scrollbars working but for the moment I cant, I tried to do a package with the new package system and I detected some painting problems while in form designing, I packaged a TMySQLDataset component and for the first time a see the grid filling a design time !. Unfortunatelly TDataSet derivatives seems to have problems at the form streaming time :(. I'm not in the office so I cant post the backtraces but it seem its a RTTI issue.

regards.

Jesus Reyes A.

Earlier message 135 lines
----- Original Message ----- From: To: Sent: Thursday, May 22, 2003 5:14 PM Subject: Re: [lazarus] TDBGrid question > Hi Jesus, > > Here is what I have done inorder for me to work with TDBGrid. > > I added/created a property named BufferCount in TDBGrid class > > property BufferCount : Integer Read FBufferCount Write SetBufferCount; > > procedure TCustomDBGrid.SetBufferCount(const Count : Integer); > begin > FBufferCount := count; > if Count > RowCount then > FDataLink.BufferCount := count > else > FDataLink.BufferCount := RowCount; > end; > > I changed UpdateBufferCount to > > procedure TCustomDBGrid.UpdateBufferCount; > begin > if BufferCount <= RowCount then > FDataLink.BufferCount := RowCount + 1 > else > FDataLink.BufferCount := BufferCount;//buffer count of this class > > end; > > The reason I did this was that I discovered when I set FDataLink.BufferCount to more than my table's number of records, I can scroll the TDBGrid fine. > > Hope you can validate if this work around is correct. > > Regards, > > Yoyong Hernan > > > > > Internet Mail Message > Received from host: > svcr-216-37-230-2.dsl.svcr.epix.net > [216.37.230.2] > > > > From: Jesus Reyes on 05/19/2003 05:19 PM GMT > > Jesus Reyes To: > Cc: (bcc: Yoyong Hernan-ET/PGI) > Subject: Re: [lazarus] TDBGrid question > > 05/20/2003 01:19 AM > Please respond to > > > > > > > > --- Michael Van Canneyt escribi�: > > > > > On Mon, 19 May 2003 wrote: > > > > > > > > > > > Hi Jesus, > > > > > > I have tried using TDBGrid and it work quite well. But I noticed > > that I cannot > > > scroll backward when my table contains more than 10, (my table > > contains 56 > > > rows). I have tried to track it down and it seems that the > > problem is somewhere > > > in TDataset or its parent(s). Can someone have a look on this? > > > > I've had this issue in the past, and I suspect has something to do > > with the buffer > > scrolling. I have not yet been able to pinpoint the exact error, > > however. > > > > The procedure you want is in dataset.inc, line 1634 > > > > Procedure TDataset.ShiftBuffers (Offset, Distance : longint); > > > > Subprocedure 'shiftbuffersdown'. > > > > I currently do not have enough time to look at it, but if someone > > else > > has, the above info may help to pinpoint the exact problem. > > > > Michael. > > > > > Sorry, I missed the original message from Yoyong. Still I can't > reproduce the problem, I have a dataset with hundreds of rows and i > can go forward/backward without problem. Can you give more details > about dbgrid geometry/dataset derivative, a backtrace? > > Thanks. > > Jesus Reyes > > _________________________________________________________ > Do You Yahoo!? > La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. > http://net.yahoo.com.mx > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives > > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Marc Weustink
to Jesus Reyes: --- Michael Van Canneyt escribi�: > In fact this is the problem that I have with the…

+ From: Jesus Reyes
+
+ 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 :)}

In some cases it might be, as long as it isn't the default case. (Think what would happen if you hit a table with over 1 million records (and yes, they do exist))

+ 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 :) .

In some cases the Recordcount is only a hint. You can use it as a kind of indication of the amount of data. Maybe you can use it to quick navigate to allmost the end of a dataset (alltough I really have no idea how one can tell a database to skip say for instance 10000 records)

Marc

Reply by email

Unknown author

To Jesus,

Can you help me how to issue another SQL command using TDBGrid?

I mean I have TIBDatabase,TIBQuery, TDatasource and TDBGrid. I need to change my sql command for my TIBQuery which is connect to TDBGrid, how can I do that. The following command does not work.

myTDBGrid.Close;
myTDBGrid.SQL.clear;
myTDBGrid.SQL.Add('new sql command');
myTransaction ..... <transaction preparation here>
myTDBGrid.Open;

The above statement does not refresh the TDBGrid with correct information.

Regards,

Yoyong

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Jesus Reyes on 05/23/2003 04:19 PM GMT

Jesus Reyes To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] TDBGrid question

05/24/2003 12:19 AM
Please respond to

--- Mattias Gaertner escribi�: > On Thu,
22 May 2003 19:43:18 -0600

Show quoted text 20 lines
"Jesus Reyes" wrote: > I thought that I corrected those details, later I will try to verify this, > thanks. > > Meanwhile feel free to do any changes later if you like we can insert > them, I wanted to get the scrollbars working but for the moment I cant, I > tried to do a package with the new package system and I detected some > painting problems while in form designing, There is a problem with non visual components. When the form move or some gtk internal layout widgets resize the coordinates are not always correct and the icons are not properly moved.

Oh, in fact i was talking of dbgrids painting at design time and specifically when the dbgrid has some content to show, I can see the proble you describe, that little shaking icons I thought it was an animation effect ;)

Show quoted text 15 lines
> I packaged a TMySQLDataset component and > for the first time a see the grid filling a design time !. Unfortunatelly > TDataSet derivatives seems to have problems at the form streaming time :(. > I'm not in the office so I cant post the backtraces but it seem its a RTTI > issue. Is this a new bug or the one found last week? Mattias

Maybe i should update my sources, my last update was when one propery (database?) duplicate was corrected

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

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email