Paging

E

Eugene Anthony

The code bellow does paging of recordset. How do I create the next and
previous button for this code? Also is there a way of implementing
paging without including adovbs.inc?


<!-- #INCLUDE FILE="adovbs.inc" -->
<html>
<head>
<title></title>
</head>
<body>
<%
Dim conn, rs
Dim currentPage, rowCount, i
currentPage = Trim(Request("CurrentPage"))
if currentPage = "" then currentPage = 1
set conn = server.CreateObject("ADODB.Connection")
conn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.MapPath("/db/upload/stelladb.mdb") & ";"
conn.open
set rs = server.CreateObject("ADODB.Recordset")
rs.CursorType = adOpenStatic
rs.PageSize = 1
rs.Open "SELECT Username, Password FROM Account",conn
rs.AbsolutePage = cInt(currentPage)
rowCount = 0
while not rs.EOF and rowCount < rs.PageSize
response.write rs("Username") & "<BR>"
response.write rs("Password") & "<BR>"
rowCount = rowCount + 1
rs.movenext
wend
response.write "<hr>"
for i = 1 to rs.PageCount
%>
<a href="paging.asp?currentPage=<%=i%>"><%=i%></a>
<%
next
%>
</body>
</html>


Eugene Anthony
 
E

Eugene Anthony

I tried this but my next and previous does not seem to appear.

<html>
<head>
<title></title>
</head>
<body>
<%
Dim conn, rs
Dim currentPage, rowCount, i
currentPage = Trim(Request("CurrentPage"))
if currentPage = "" then currentPage = 1 end if
set conn = server.CreateObject("ADODB.Connection")
conn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.MapPath("/db/upload/stelladb.mdb") & ";"
conn.open
set rs = server.CreateObject("ADODB.Recordset")
rs.CursorType = 3
rs.PageSize = 1
rs.Open "SELECT Username, Password FROM Account",conn
rs.AbsolutePage = cInt(currentPage)
rowCount = 0

while not rs.EOF and rowCount < rs.PageSize
response.write rs("Username") & "<BR>"
rowCount = rowCount + 1
rs.movenext
wend
%>
<% If currentPage > 1 Then %>
<A HREF="paging.asp?currentPage=<%=currentPage-1%>">Prior</A>
<% End If %>

<% If currentPage < rs.PageCount Then %>
<A HREF="paging.asp?currentPage=<%=currentPage+1%>">Next</A>
<% End If %>
</body>
</html>


Eugene Anthony
 
E

Eugene Anthony

I found the solution which is CInt()

<% If CInt(currentPage) > 1 Then %>
<A HREF="paging.asp?currentPage=<%=currentPage-1%>">Prior</A>
<% End If %>

<% If CInt(currentPage) < CInt(rs.PageCount) Then %>
<A HREF="paging.asp?currentPage=<%=currentPage+1%>">Next</A>
<%

Eugene Anthony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top