ASP, Page through and Show In columns

They have: 34 posts

Joined: Feb 2002

I'm trying to show 3 records across and 3 records down on my page. Then I want to be able to page to the next set of records and do the same thing. The code I'm using now kind of works.. It lists the id in the columns but will not page through my record set. If I could get some help I would very apreciative.

MY CODE!

___________________________________________________________________

<?php
DIM objConn
Set objConn
= Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server
.MapPath ("/testsites/crazy/db/cart.mdb") & ";"
objConn.Open

DIM mySQL
mySQL
= "SELECT * FROM products"

DIM objRS
Set objRS
= Server.CreateObject("ADODB.Recordset")
objrs.CursorLocation = ' adUseClient
objRS.Open mySQL, objConn
objrs.PageSize = 3
intPageCount = objrs.PageCount

Select Case Request("Action")
    case "<<"
        intpage = 1
    case "<"
        intpage = Request("intpage")-1
        if intpage < 1 then intpage = 1
    case ">"
        intpage = Request("intpage")+1
        if intpage > intPageCount then intpage = IntPageCount
    Case ">>"
        intpage = intPageCount
    case else
        intpage = 1
end select


DIM recCount
IF Not objRS.EOF THEN
Response.Write "<table width=100>"
recCount = 0
Do WHILE NOT objRS.EOF
IF recCount Mod 3 = 0 THEN
IF recCount <> 0 THEN Response.Write "</tr>"
Response.Write "<tr><td>"&objRS("id")&"</td>"
ELSE
Response.Write "<td>"&objRS("id")&"</td>"
END IF
recCount = recCount + 1
objRS.MoveNext
Loop
Response.Write"</tr></table>"
ELSE Response.Write "Sorry, there are no records in our database."
END IF
?>

<?php
objrs
.AbsolutePage = intPage
For intRecord = 1 To objrs.PageSize
?>

<?php
    objrs
.MoveNext
If objrs.EOF Then Exit For

Next

objrs
.Close
set objrs
= Nothing
?>

Page:

<?php
=Intpage & " of " & intpagecount
?>

They have: 34 posts

Joined: Feb 2002

woops.. you can view the page at http://www.finalphase.org/testsites/crazy/test.asp

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Venom,

It looks like you're executing the complete Recordset, try changing this line:

Do WHILE NOT objRS.EOF

To:

Do While recCount < objrs.PageSize AND Not objRS.EOF

You will have to change your objRS.PageSize to 12 if you want to show 3x3, otherwise you will only get 3x1.

PJ | Are we there yet?
pjboettcher.com

They have: 34 posts

Joined: Feb 2002

Ok, that worked but now it will not go onto the next set of records.. page and be viewed here.. http://www.finalphase.org/testsites/crazy/test.asp

detox's picture

They have: 571 posts

Joined: Feb 2001

paging was working fine when I went to that link....

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Just realized something! For the paging to work you have to move this line:

objrs.AbsolutePage = intPage

Under this line:

IF Not objRS.EOF THEN

Then everything should work! Your query was executing before it knew what page it was on, so it was always on the first page.

PJ | Are we there yet?
pjboettcher.com

They have: 34 posts

Joined: Feb 2002

Thank you peter for all you help. I also had to move

For intRecord = 1 To objrs.PageSize
objrs.MoveNext
If objrs.EOF Then Exit For

to under:

ELSE Response.Write "Sorry, there are no records in our database.

Again thanks for you help.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.