To read the article online, visit http://www.4GuysFromRolla.com/webtech/060399-1.shtml

Error Handling in ASP


You just finished your ASP application in time, barely making the dealine! As you upload the final version to the webserver, you receive an email from your supervisor indicating that he's ready for your demo. You confidently stride into his office and give him instructions on accesses the application through the Intranet.

Your boss comes to the first page, and is asked to enter his name. You've created a slick, customized feel to the site, recording the user and his or her preferences in a database. Your boss types in his name, "The Pointy Haired Boss," and hits the submit button. Instead of being taken to the next page, he sees the following text pop up on the screen:

Microsoft OLE DB Provider for ODBC Drivers error ' 80004005' [Microsoft][ODBC Access 97 ODBC driver Driver] syntax wrong near '

Please note that I just made this error message up, so, please, no emails asking about how one gets this error by entering his name!

You get one of those looks from your boss, a look that says, "I hope you weren't expecting a positive performance review."

There's nothing worse to an end user than to see those dreaded ADO errors. They are misformatted, cryptic, and leave the user wondering what they are suppose to do. Your average end user doesn't know ODBC from OLE. So how can you prevent these nasty error messages?

First you must insert at the top of your ASP page:

<% On Error Resume Next %>

This will tell ASP to just skip over any errors, instead of halting execution and printing out a nasty error message. You may be tempted to leave it at this, although if you do, and errors occur, your users won't be aware of them. They will think their information was correctly saved, when in actuality it wasn't due to an ADO error.

What, then, do we want to do if there is an error? Well, the idea situation would be to let the end user know that an error had occurred and will be worked on, and automatically email technical support with the ADO error messages. So that is what we will do!

  • Page 2


  • Article Information
    Article Title: 4GuysFromRolla.com - Error Handling in ASP
    Article Author: Scott Mitchell
    Published Date: Thursday, June 03, 1999
    Article URL: http://www.4GuysFromRolla.com/webtech/060399-1.shtml


    Copyright 2014 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers