Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT: COnnection time out in ADO.Net

Status
Not open for further replies.

Dude81

Programmer
Mar 16, 2005
7
US
I use the connection timeout property for creating the SQLConnection. I am basically trying to open the connection to my remote database and if that fails I need to switch to my local database.
However ADO.net is taking around 40 seconds to figure out that it cannot open the connection. i have specified the connection timeout as 5 seconds.

Am i missing anything???

Thanks in advance
-Himanshu
 
Yes... (and this is subtle) the connection time out has nothing to do with this.. The problem is that the system is unavailable and the issue of resolving the PC to an instance of SQL server is what you are experiencing - basic network connection, not Database.)

What I do in this situation is send a ping out to the server before I try to connect. If the ping comes back within .01 of a second, I will then try to connect (time configurable)


A couple of options.. Just send a [blue]Ping -n1[/blue] command via a shell type call. This tells the ping to only try a single call. If the command is still there after .01 then the server is declared unavailable.

Another choice (better in dotnet) is to go to the trouble of calling ping at the api level.


will give you source..

HTH


Rob
 
Hi,
Thanks for your suggestion BUT, this is a multiple client single server environment. And we cant overload the server by trying to Ping it everytime we try to make the connection. Basically this is the code that has been ported from VB to VB.Net and the argument is that ADO used to return a lot quicker than ADO.net that is taking around 35 - 40 seconds.
 
Dude


What does your code look like?

What is your connection object? What other objects are you using? What does your connection string look like?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top