ADO paging

L

Luka POZVEK

Hello!

I have a problem regarding ADO paging. I have a simple .mdb database to
which i connect through ADO. It contains 42 records (each has 2 fields).
I've set up a asp code, which "pages" through those records. The problem is,
it doesn't show the first three records (it begins with number 4) and when
it comes to the last page, the "next" button should be disabled (span), but
it's not. I would really appreciate any help or tip. Thanks.

*Datastore.asp contains string for provider.

CODE:

<%@language = "vbscript" %>
<% Option Explicit %>
<!-- #INCLUDE FILE="datastore.asp" -->
<!-- METADATA TYPE="TypeLib" FILE="C:\Program files\Common
Files\system\ado\msado15.dll" -->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>New Page 1</title>
</head>

<body>
<%
Dim rsData, strCurrent, strConnect, element, i, ele, strNarek, strPage,
strAll
strNarek = Chr(34)
Set rsData = Server.CreateObject("ADODB.RecordSet")
rsData.PageSize = 7
rsData.CursorLocation = adUseClient
rsData.Open "Datumi", strConnect

SELECT Case Request.QueryString("PAGE")
Case ""
strCurrent = 1
Case Request.QueryString("PAGE") < 1
strCurrent = 1
Case Request.QueryString("PAGE") > rsData.PageCount
strCurrent = rsData.PageCount
Case else
strCurrent = Request.QueryString("PAGE")
End Select

strAll = rsData.PageCount
rsData.AbsolutePage = strCurrent

Response.Write("<TABLE Border=1><TR>")
For each element in rsData.Fields
Response.Write ("<TD>" & element.Name & "</TD>")
rsData.MoveNext
Next
Response.Write ("</TR>")

For i = 1 to rsData.PageSize
If Not rsData.EOF then
Response.Write ("<TR>")
For each ele in rsData.Fields
Response.Write("<TD>" & ele.Value & "</TD>")
Next
Response.Write ("</TR>")
rsData.MoveNext
End if
Next
Response.Write ("</TABLE>")

strPage = "thisfile.asp"
Response.Write("&nbsp;<A HREF=" & strNarek & strPage & "?PAGE=1" & strNarek
& ">First</A>")

If strCurrent = 1 then
Response.Write("&nbsp;<SPAN>Previous</SPAN>")
Else
Response.Write("&nbsp;<A HREF=" & strNarek & strPage & "?PAGE=" &
strCurrent - 1 & strNarek & ">Previous</A>")
End If

If strCurrent = strAll then
Response.Write("&nbsp;<SPAN>Next</SPAN>")
Else
Response.Write("&nbsp;<A HREF=" & strNarek & strPage & "?PAGE=" &
strCurrent + 1 & strNarek & ">Next</A>")
End If

Response.Write("&nbsp;<A HREF=" & strNarek & strPage & "?PAGE=" & strAll
& strNarek & ">Last</A>")


rsData.Close
Set rsData = Nothing
%>

</body>

</html>
 

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,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top