Solved

Test Remote Database Connections

Posted on 2011-09-28
5
241 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

12 Experts available now in Live!

Get 1:1 Help Now