Print Page | Close Window

Check for SQL connectivity, if no redirec

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7308
Printed Date: 30 March 2026 at 7:27am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Check for SQL connectivity, if no redirec
Posted By: wistex
Subject: Check for SQL connectivity, if no redirec
Date Posted: 16 November 2003 at 6:20am

My SQL Server went down and I had the dreaded:

Originally posted by Internet Explorer Internet Explorer wrote:

Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

Is there away to do something like this:

Check if SQL database is up.

If up, then connect to database with connection string

else, redirect to a static page that doesn't use SQL

or

show the page but use a different include that doesn't use SQL if only the include uses SQL.

Thanks.



-------------
http://www.wistex.com" rel="nofollow - WisTex Solutions
http://www.caribbeanchoice.com/forums" rel="nofollow - CaribbeanChoice Forums



Replies:
Posted By: ljamal
Date Posted: 16 November 2003 at 2:38pm
The only way is ignore all suppress all errors with:

On Error Resume Next

and then after you connect to the database check for an error

if Err.Number<>0 then
     Response.Redirect (strURL)
end if

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: wistex
Date Posted: 16 November 2003 at 5:33pm

That's cool.

Some of my static pages pull some information from the database (i.e. check to see if they are logged in to the forum or show a poll from the forum*), but that information is not required for the static part of the site. Its just a nice enhancement.

(*I'm creating a universal login to the website using WWF to store the users.)

With the code you gave above, I should also be able to tell it to not use certain includes or code that requires access to the database.

I think I am going to use that in all the code I write from now on.  I'd rather have them see my static pages and not get a 500 error.

Error checking is a good thing! 



-------------
http://www.wistex.com" rel="nofollow - WisTex Solutions
http://www.caribbeanchoice.com/forums" rel="nofollow - CaribbeanChoice Forums


Posted By: ljamal
Date Posted: 16 November 2003 at 9:21pm
I disable errors in general because I'd rather have the errors emailed or logged for possible troubleshooting rather than being displayed to the user who has no idea what the error is.

The code is part of my check for error sub

Sub CheckError (strURL)
if Err.Number<>0 then
     Response.Redirect (strURL)
end if
End Sub

It's easier to write CheckError("default.asp") then the if then statement over and over again.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net