paging error handling

Discussion in 'ASP General' started by solomon_13000, Jun 25, 2006.

  1. I inserted an error handling code for the code bellow. What happen is
    the page is taking a long time to load. Upon loading it takes me to
    "page not found" of microsoft internet explorer. How do I solve the
    problem?


    <html>
    <head>
    <title></title>
    </head>
    <body>
    <%
    on error resume next
    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/stellad.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 err <> 0 then
    Response.Write "<center><font class='error'>" & Err.number & ":" &
    Err.Description & "</font></center><br>"
    conn.Close
    Set conn = nothing
    On Error Goto 0
    Response.End
    End If
    conn.close
    set conn = nothing
    %>

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

    </body>
    </html>


    It works, however if I change the database name

    valid db name: stelladb.mdb to an invalid db name: stellad.mdb

    It cant handle the error. The page takes time to load, and the result
    is "page not found" of microsoft internet explorer.
     
    solomon_13000, Jun 25, 2006
    #1
    1. Advertising

  2. > on error resume next
    > 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/stellad.mdb") & ";"
    > conn.open


    If you're trying to trap errors in connecting to the database, then put some
    error handling right here! Waiting until AFTER trying to execute 40
    statements, all of which depend on the success of this one, is not going to
    get you too far.

    A
     
    Aaron Bertrand [SQL Server MVP], Jun 25, 2006
    #2
    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. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,782
    Scott Allen
    Oct 8, 2004
  2. wh1974
    Replies:
    0
    Views:
    2,454
    wh1974
    Jan 12, 2005
  3. Red
    Replies:
    1
    Views:
    734
  4. Mark Tarver
    Replies:
    22
    Views:
    1,337
    J Kenneth King
    Apr 26, 2009
  5. Peter
    Replies:
    34
    Views:
    1,975
    James Kanze
    Oct 17, 2009
Loading...

Share This Page