Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 9th, 2004, 06:13 AM
Registered User
 
Join Date: Sep 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Paging with ASP

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 %>


<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>






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Paging Query Bozmeister ASP.NET 3.5 Basics 3 November 8th, 2008 02:20 PM
Paging using asp and javascript x_ray Classic ASP Basics 2 February 4th, 2006 06:14 AM
Paging in ASP. rupen Classic ASP Basics 0 October 4th, 2005 08:34 AM
Need Help!! ASP Paging stitch Classic ASP Databases 5 August 26th, 2003 05:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.