Solved

Detect Database Connection and redirect if broken

Posted on 2003-11-11
1
356 Views
Last Modified: 2010-05-18
I'm developing an application that connects to a local SQL Server database via IP address.  The application is working fine but I would like to add a function that checks to make sure the connection is available and if the connection is not available ("SQL Server does not exist or access denied") then I'd like it to be able to redirect to a custom page to notify the visitor.  Here is the connection string I'm using within an include page.

Set ConnSQL_STRING = Server.CreateObject("ADODB.Connection")
ConnSQL_STRING.open "Provider=sqloledb;Data Source=XX.XX.XX.XXX,1433;Network Library=DBMSSOCN;Initial Catalog=store2;User ID=xxxx;Password=xxxxxx;"
0
Comment
Question by:djbyron
1 Comment
 
LVL 58

Accepted Solution

by:
amit_g earned 125 total points
ID: 9725178
Set ConnSQL_STRING = Server.CreateObject("ADODB.Connection")

on error resume next

ConnSQL_STRING.open "Provider=sqloledb;Data Source=XX.XX.XX.XXX,1433;Network Library=DBMSSOCN;Initial Catalog=store2;User ID=xxxx;Password=xxxxxx;"

if (Err.Number <> 0) then
      'There was an error
      Response.Redirect "ErrorPage.asp"
end if

'Cancel the on error resume next
on error goto 0
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now