Solved

Detect Database Connection and redirect if broken

Posted on 2003-11-11
1
359 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
UTC (timezone) without using an API 16 50
SQL Filter Question 8 86
Help with query 3 31
Multiflying 2 Input Text On a Table 7 31
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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