If you don’t properly handle ASP (Active Server Pages) errors, the message "The page cannot be displayed" will be sent to your Web site's visitor. To avoid that, use the "On Error Resume Next" statement and the Err Object to handle errors.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact Advertise on Bucaro TecHelp Advertise Here RSS News Feeds News Feeds


Hello World! Computer Programming for Kids and Other Beginners

Hello World! Computer Programming for Kids and Other Beginners

This book provides a gentle but thorough introduction to computer programming. It's written in language a kid can follow, but anyone who wants to learn how to program a computer can use it. Even adults.

Teaches using the powerful object-oriented but easy-to-use open source Python programming language.

Click Here

Handling ASP Errors

ASP will let you know an error occurs, usually by displaying the message "The page cannot be displayed" along with the code "HTTP 500 - Internal Server Error - ASP Error - Internet Information Sever" and a terse message giving some usually not too helpful information about what caused the error. This is NOT the type of message you want to send to your Web site's visitor.

ASP errors are basically of two types. The first type is "syntax" errors or "logic" errors caused by the programmer. The second type "run-time" errors generated by the system. Examples of system errors are a file or database that ASP can't perform an operation on because of low system resources of a loss of connectivity.

There are two ways to respond to an error. The first way is to just let them happen and expose your Web site's visitors to the default error message, or by "Handling" the error. Handling the error involves determining where an error might occur in your code, for example in code that accesses a file or database, and adding code to do something about the error.

Things you might do about an error are display a friendly error message to the user, perform any clean up tasks required by the error, log the error, or notify the webmaster of the error.

There are two ways to handle an error. The first way is to use VBScript's "On Error Resume Next" statement. Below is an example of using the "On Error" statement.

<%
Set cn = CreateObject("ADODB.Connection")

On Error Resume Next
cn.Provider = "sas.localprovider.1"
cn.Properties("Data Source") = "c:\testdata"
cn.Open
cn.Close
%>

This code creates a database connection, configures the connection, and then opens and closes the connection. If an error occurs when attempting to configure and use the database connection, the "On Error Resume Next" will cause execution of the code to continue on the next line after the line that caused the error.

The "On Error Resume Next" stops the default error message from appearing and allows the webpage to continue execution, but it doesn't do anything about the error.

The second way to handle an error is to use the Err object. The properties and methods of the Err object are listed below.

Properties

.Number
.Description
.Source

Methods

.Clear
.Raise

Programming Sections

RSS Feed RSS Feed

Active Server Pages


[Site User Agreement] [Advertise on This site] [Search This Site] [Contact Form]
Copyright©2001-2011 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268