Board index » delphi » only display 20 Records per page?

only display 20 Records per page?

Hi

Im nearly a beginner in ADO. (I use Access 97 and Webbroker components.)
My Problem:
When I get 100 Records from TADOquery after my SQL statement, I want only
display 20 Records per page. With a "prev/next"-Button I want to browse to
the next or previous 20 records.
How can I do this positioning?

 

Re:only display 20 Records per page?


Hi back,

How are you displaying the records? If you're using a dbgrid, then I think
that it does this automatically, and you'd be fighting it to do it yourself.

If you're reading the records into some kind of list, stringgrid, or other
fields on the screen, then you would have to worry about it. For this, how
about bookmarking the list when you open the query (since it reads the first
record), loading up the display. At this point, to scroll forward, simply
read, to go backwards, go back to your bookmark, then read backwards to get
your display.

Mike Walsh

Quote
"dierk" <di...@csslabs.de> wrote in message news:3ae6f405_2@dnews...
> Hi

> Im nearly a beginner in ADO. (I use Access 97 and Webbroker components.)
> My Problem:
> When I get 100 Records from TADOquery after my SQL statement, I want only
> display 20 Records per page. With a "prev/next"-Button I want to browse to
> the next or previous 20 records.
> How can I do this positioning?

Re:only display 20 Records per page?


If your doing it in a webform (as you implied) you have to reissue the query
for each press of the Prev/Next button so you have to know a starting and
ending value in you source data (dont try record nummber it will get you in
trouble, use a key like first customer no. and last customer number ).  Then
set maxrecords in your adoquery to 20. You will have to maintain your own
state and remember the first and last record by key that was in the result
set of the query.

Re:only display 20 Records per page?


I prefer to write paging code myself but for your purposes look at

PageCount,
PageSize,
AbsolutePage

In ADO SDK.

-Sen
<  ===================From SDK ======================== >
Using Pages
Use the PageCount property to determine how many pages of data are in the
Recordset object. Pages are groups of records whose size equals the PageSize
property setting. Even if the last page is incomplete because there are
fewer records than the PageSize value, it counts as an additional page in
the PageCount value. If the Recordset object does not support this property,
PageCount will be -1 to indicate that the PageCount is indeterminable.

Use the PageSize property to determine how many records make up a logical
page of data. Establishing a page size allows you to use the AbsolutePage
property to move to the first record of a particular page. This is useful in
Web-server scenarios when you want to allow the user to page through data,
viewing a certain number of records at a time.

This property can be set at any time, and its value will be used for
calculating the location of the first record of a particular page.

Use the AbsolutePage property to identify the page number on which the
current record is located. Again, the provider must support the appropriate
functionality for this property to be available.

AbsolutePage is 1-based and equals 1 when the current record is the first
record in the Recordset. Set this property to move to the first record of a
particular page. Obtain the total number of pages from the PageCount
property.

Other Threads