Solved

Test Remote Database Connections

Posted on 2011-09-28
5
245 Views
Last Modified: 2012-05-12
Hello,

Is it possible to test a connection string to a remote database and return a True / False if the connection was successful?

If so, any articles / code snippets would be much appreciated.

Thanks,


D.
0
Comment
Question by:NewFourWalls
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 500 total points
ID: 36719055
Try this code, in connection string replace server= with correct IP address of remote server:

<%
on error resume next

dim strConn : strConn = "Provider=SQLOLEDB; Server=192.168.0.100; Database=DBNAME; User ID=UNAME; Password=PWD;"
set conn = Server.CreateObject("ADODB.Connection")
conn.Open(strConn)


if(conn.State = 1) then
    Response.Write("Connection successful <br>")
else
    Response.Write("Connection failed, "& err.Description &" <br>")
end if    
On Error Goto 0
%>
0
 

Author Comment

by:NewFourWalls
ID: 36813734
Hi, thanks for that, however it is extremely slow.

I have users who have 2 - 10 remote database connections, i tested it with 2 and it took 30-45 seconds to return a response.

Is there any way i could speed it up and these functions will run quite often.

Thanks,


D.
0
 
LVL 15

Expert Comment

by:pateljitu
ID: 36816136
Based on your post I am judging that all SQL server instances are running at different location and have a public facing IP address, ASP page that is accessing SQL server is on another server, if that's the case I would say yes the processing time will be a bit more and just using classic asp we cannot speed up the process.

Another idea would be create a web service that would sit on each SQL server that check the SQL connectivity and output TRUE or FLASE as return value and in your ASP page access the web service and retrieve the value (which would be much more faster for sure)

Good Luck.
0
 

Author Comment

by:NewFourWalls
ID: 36816426
Hi Pateljitu,

Thank you for your help. Unfortunately it's not really possible to use the webservice option but at least I now know there is no viable option in ASP.

Thank you.


D.
0
 

Author Closing Comment

by:NewFourWalls
ID: 36816428
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Auto Submit on dropdown box 14 78
Question about ASP Including Files 6 64
Save ms data to server side. 19 59
Use Mid in Html 6 22
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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