Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - show database results in pages
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

show database results in pages

 Post Reply Post Reply Page  12>
Author
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post Topic: show database results in pages
    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

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 30 April 2004 at 8:04am
Access, MSSQL, MySQL?
What's the database?
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post Posted: 30 April 2004 at 11:11am
It's MS Access
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 30 April 2004 at 12:07pm
http://www.4guysfromrolla.com/webtech/070500-1.shtml

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

Edited by ljamal
Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.