Paging

Discussion in 'ASP General' started by Eugene Anthony, Jun 11, 2006.

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

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Eugene Anthony, Jun 11, 2006
    #1
    1. Advertising

  2. Eugene Anthony

    Mike Brind Guest

    Mike Brind, Jun 11, 2006
    #2
    1. Advertising

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

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Eugene Anthony, Jun 12, 2006
    #3
  4. 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

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Eugene Anthony, Jun 12, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yangtsi River

    using Paging in Datagrid

    Yangtsi River, Jul 9, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    362
    Benjie Fallar
    Jul 9, 2003
  2. Saravana

    Re: Custom paging

    Saravana, Jul 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    435
    Saravana
    Jul 10, 2003
  3. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,876
    Scott Allen
    Oct 8, 2004
  4. wh1974
    Replies:
    0
    Views:
    2,492
    wh1974
    Jan 12, 2005
  5. Red
    Replies:
    1
    Views:
    771
Loading...

Share This Page