Solved

Test Remote Database Connections

Posted on 2011-09-28
5
243 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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 information …
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

822 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