Click to See Complete Forum and Search --> : Splitting records with asp/sql/ado....????


Wollington
09-29-2001, 03:21 PM
I have an asp page which writes out all of the data of one table in a certain DB. There are currently over 100 records and it will continue to grow. However when it writes them out it only does up to about 90 records.
It is also fairly slow so I've decided I want to split it into say 30 records a page.

So how can I split the records and dynamically create enough pages?

Thanks

------------------
Microsoft has acknowledged that its engineers substituted certain file names with the phrase, "Netscape engineers are weenies," in some of its internet software.

Oh well now we all know why Nutscrape is so crap!

bryce777
09-29-2001, 04:18 PM
There are a couple ways to do it, but most likely you will want to edit the query itself so that it returns the right rows for you, or you can just step through the same query to the right rows for the page using the recordset. You will also have to get a count from the DB to know how many pages to show in the index. Then, you have a link for each page which basically posts to the same form to create that page.

I hope this makes sense. It's not too tough if I explained it ok.



------------------
system specs:
Voodoo 5 5500 agp
tyan 1834d tiger 133 dual 800eb 133mhz FSB
via chipset 133 via apollo pro (don't make this mistake)
256 MB RAM
2 maxtor 60gig ata100 drives
promise ata100 controller
liteon 52 truex cdrom
Linksys ethernet 10/100
Soundblaster Live! (what's so exciting about it??) value edition
300watt power supply (inwin)
about 7 pounds of fans (I'm not kidding)
Suse 7.1(god gnome is crappy compared to CDE)/win2000 based system

Grizzly
10-01-2001, 08:10 PM
Just to add:

I typically have 2 vars.
- StartRow
- MaxRows

Say StartRow will be "1" by default, and "MaxRows" will be 30 by default.


You can generate "Previous & Next" buttons, which link to the same page you're on, except it will pass "StartRow=X" through the URL. X being the value of which Record you would like to start on.

So if StartRow is it's default of 1, than you want to return StartRow through (StartRow+MaxRows)-1, which is 1-30.

If StartRow is 5, than you still want to return StartRow through (StartRow+MaxRows)-1, which is 5-35.


Simple enough?
You will also need to work in logic for your Previous & Next buttons, so they'll only appear if needed.

For example, for the NEXT button you need to say something like:

if( StartRow+MaxRows < TotalRecordSet ){
print "<a href=...?StartRow=StartRow+MaxRows>Next</a>";
}


Similiar logic should be applied to the Previous button.

Catch my drift? I've written such functions in both Cold Fusion & PHP, but I've never really worked with ASP. If you need help with it let me know, I'll be glad to elaborate further for ya http://www.sharkyforums.com/ubb/smile.gif

Wollington
10-02-2001, 05:56 AM
Thanks guys.
Fortunately there are some recordset objects in ADO which allow me to do just this. So after reading about 20 articles all of which do things in a different way and none of which explain how they are doing it i've managed to get a working version http://www.sharkyforums.com/ubb/smile.gif

------------------
Microsoft has acknowledged that its engineers substituted certain file names with the phrase, "Netscape engineers are weenies," in some of its internet software.

Oh well now we all know why Nutscrape is so crap!