Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7015565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:40:09+00:00 2026-05-27T22:40:09+00:00

I wish to do the following … Provide a page a developer can redirect

  • 0

I wish to do the following … Provide a page a developer can redirect to provided an error occurs … like a vb error connection couldn’t open or object couldn’t be found … or a database error is raised … but since I moved the redirect into a sub the page doesn’t actually redirect … Is it possible that I simply can’t redirect from a sub? Seems weird.

Run a stored procedure that raises an error

Dim cmd
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "spReturnDBException"
cmd.Execute

Call a handle errors function that sets up some session parms and redirects if neccessary

HandleErrors con _
            , Request.ServerVariables("PATH_INFO") _
            , "An error occurred while trying to save sessions." _
            , "Actual Error: " + Err.Description + " EmpNo: " + Session("EmpNo") _
            + ".  QueryString: " + Request.Querystring _
            , 0

This would be the sub called.

sub HandleErrors( connection, WebPagePath, GenericErrorMessage, DebugInfo, Severity)


//Check for vb errors
if Err.Number <> 0 Then

    Session("WebPagePath") = WebPagePath 
    Session("SafeErrorMessage") = GenericErrorMessage 'Session("SafeErrorMessage") + "A connection was dropped while trying to complete sessions."
    Session("DebugInfo") = DebugInfo ' Err.Description
    Session("LineNo") = Err.Line 
    Session("StackTrace") = "" 
    Session("Severity") = Severity 

    response.redirect("Error.asp")  

    //error occurs
elseif connection.Errors.count <> 0 then 

    response.write("a database error occurred.")
    // Store safe error message / # in session
    Session("WebPagePath") = WebPagePath 
    Session("SafeErrorMessage") = GenericErrorMessage 'Session("SafeErrorMessage") + "An error has occurred while trying to save sessions."
    Session("DebugInfo") = DebugInfo '"Some extra added debug info from the webpage"
    Session("LineNo") = 0 
    Session("StackTrace") = ""
    Session("Severity") = Severity

    Dim objError
    for each objError in connection.Errors

        // Store safe error number in session
        Session("SafeErrorNumbers") = Session("SafeErrorNumbers") + objError.Description
        if connection.Errors.Count > 1 then
            Session("SafeErrorNumbers") = Session("SafeErrorNumbers") + "|"
        end if 

    next 

    response.Redirect("Error.asp")  
end if

Err.Clear

end sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:40:09+00:00Added an answer on May 27, 2026 at 10:40 pm

    To display the Error line number:

    set objError = Server.GetLastError()
    strErrorLine =  objError.Line
    

    Here are a couple threads on using Err.line:

    http://www.daniweb.com/web-development/asp/threads/11615

    http://www.sitepoint.com/forums/showthread.php?279612-ASP-Error-Handling.-Err.Line-weird-behavior

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to produce the following layout within a header div on my page,
I wish to create an enum-like list of constants with the following properties: The
I wish to have a newsletter on my home page. I found the following
I have a page where I wish to render the following html (a small
I wish to do something like the following in my data layer public IEnumerable<{string,int}>
I wish to develop an application in VB.NET to provide to following functionality and
I wish to download and open the following tar.gz file in R: http://s.wordpress.org/resources/survey/wp2011-survey.tar.gz Is
I am a java devloper and I wish to convert following code to java
I wish to define the following typeclass Mapping : {-# LANGUAGE MultiParamTypeClasses #-} class
I wish to use the method with the following signature: exec(String command, String[] envp,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.