ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Handling exceptions when opening database --> Part 4

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
180 active users
913 visitors today
1200 pages today
how is this done?
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
ASPRSS
ShawThing

Now open source with SourceForge!

Displaying the exception...

The DatabaseException function simply displays the error message using the description property of the Error object as shown below...

function DatabaseException ( e )
{
   Out ( 'An error has occured while connecting to the database:' );

   Out ( '<p>"' + e.description + '"' );

   Out ( '<p>Don\'t despair - this problem is probably well-documented in my <a href="http://CoverYourASP.com/Trouble.asp">trouble-shooting</a> section.' );

...then sends an email to BadDB@yourdomain.com describing the problem. I'm hoping never to get one of these emails from the CoverYourASP site!

   // make up the message body
   var sBody = 'The file "' + sURL + '?' + Request.QueryString ( ) + '" generated a database error\n\n';

   sBody += sMessage;

   // send the email
   SendEmail ( 'Database.Exception', 'BadDB@' + sHostDomain, '', 'Reporting exception', sBody );
}

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?