?
Solved

Detect Database Connection and redirect if broken

Posted on 2003-11-11
1
Medium Priority
?
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 58

Accepted Solution

by:
amit_g earned 500 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 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