Print Page | Close Window

show database results in pages

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10227
Printed Date: 31 March 2026 at 4:33pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: show database results in pages
Posted By: zMaestro
Subject: show database results in pages
Date Posted: 30 April 2004 at 3:38am

I've a database containing about 1500 record. What's the simplest way i can show the result in pages, so every page for example contains only 50 or 100 records.

set RSnav = server.createobject ("ADODB.recordset")
SQLnav = "SELECT * FROM TableName"
RSnav.open SQLnav, Conn, 1, 3
While Not RSnav.EOF
response.write " " & RSnav("Field") & "<br>"
RSnav.MoveNext : Wend
RSnav.close : set RSnav=nothing

 

thanks




Replies:
Posted By: ljamal
Date Posted: 30 April 2004 at 8:04am
Access, MSSQL, MySQL?
What's the database?


-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: Semikolon
Date Posted: 30 April 2004 at 10:33am
download the WebWizGuestbook and have a look at the code in there, I think it is what you are looking for
If you get problems it's just to come back and ask!


Posted By: ljamal
Date Posted: 30 April 2004 at 10:45am
I wouldn't suggest doing that as all WWG apps used ADO for paging and ADO paging is the least efficient manner of paging. Depending on the database being used array paging or stored procedure paging would be much better.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: zMaestro
Date Posted: 30 April 2004 at 11:11am
It's MS Access


Posted By: Semikolon
Date Posted: 30 April 2004 at 11:44am
Originally posted by ljamal ljamal wrote:

I wouldn't suggest doing that as all WWG apps used ADO for paging and ADO paging is the least efficient manner of paging. Depending on the database being used array paging or stored procedure paging would be much better.


okay.. but at least it works


Posted By: ljamal
Date Posted: 30 April 2004 at 12:07pm
http://www.4guysfromrolla.com/webtech/070500-1.shtml - http://www.4guysfromrolla.com/webtech/070500-1.shtml

I never said it didn't work, just that there were better manners of doing so.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: zMaestro
Date Posted: 30 April 2004 at 1:00pm

<%@ Language = VBSCRIPT %>
<% Option Explicit %>
<%
Dim iStart  : iStart = Request("Start")
Dim iOffset : iOffset = Request("Offset")

if Not IsNumeric(iStart) or Len(iStart) = 0 then
 iStart = 0
else
 iStart = CInt(iStart)
end if

if Not IsNumeric(iOffset) or Len(iOffset) = 0 then
 iOffset = 10
else
 iOffset = Cint(iOffset)
end if

Response.Write "Viewing " & iOffset & " records starting at record " & iStart & "<BR>"

Dim objConn, objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=MP3"

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "SELECT * FROM Mp3List", objConn

Dim aResults
aResults = objRS.GetRows

objRS.Close : Set objRS = Nothing
objConn.Close : Set objConn = Nothing

Dim iRows, iCols, iRowLoop, iColLoop, iStop
iRows = UBound(aResults, 2)
iCols = UBound(aResults, 1)

If iRows > (iOffset + iStart) Then
 iStop = iOffset + iStart - 1
Else
 iStop = iRows
End If

For iRowLoop = iStart to iStop
 For iColLoop = 0 to iCols
  Response.Write aResults(iColLoop, iRowLoop) & " "
 Next
  Response.Write "<BR>"
Next 

Response.Write "<P>"
if iStart > 0 then
 Response.Write "<A HREF=""GetRows.asp?Start=" & iStart-iOffset & _
                    "&Offset=" & iOffset & """>Previous " & iOffset & "</A>"
end if

if iStop < iRows then
 Response.Write " <A HREF=""GetRows.asp?Start=" & iStart+iOffset & _
                    "&Offset=" & iOffset & """>Next " & iOffset & "</A>"
end if
%>

Sounds logic and easy, I'll try it and come back to you



Posted By: zMaestro
Date Posted: 01 May 2004 at 11:05am

the line:

aResults = objRS.GetRows

stops the code from running.. any help?




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net