Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Check for SQL connectivity, if no redirec
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Check for SQL connectivity, if no redirec

 Post Reply Post Reply
Author
wistex View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 30 August 2003
Location: United States
Status: Offline
Points: 877
Post Options Post Options   Thanks (0) Thanks(0)   Quote wistex Quote  Post ReplyReply Direct Link To This Post Topic: Check for SQL connectivity, if no redirec
    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.

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
wistex View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 30 August 2003
Location: United States
Status: Offline
Points: 877
Post Options Post Options   Thanks (0) Thanks(0)   Quote wistex Quote  Post ReplyReply Direct Link To This Post 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! 



Edited by wistex
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.