Splitting records with asp/sql/ado....????

Sharky Forums


Results 1 to 4 of 4

Thread: Splitting records with asp/sql/ado....????

  1. #1
    Tiger Shark
    Join Date
    Mar 2001
    Location
    Staffordshire, UK
    Posts
    963

    Question Splitting records with asp/sql/ado....????

    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!
    Bygones!
    You only Die once

  2. #2
    Tiger Shark
    Join Date
    Feb 2001
    Location
    Satan Country
    Posts
    564

    Post

    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
    I'm half Scottish and half French.

    I surrender to alcohol.

  3. #3
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    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


  4. #4
    Tiger Shark
    Join Date
    Mar 2001
    Location
    Staffordshire, UK
    Posts
    963

    Cool

    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

    ------------------
    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!
    Bygones!
    You only Die once

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •