I have a simple piece of code in a .NET console application that tries to open an SQL connection to a server:
using (SqlConnection connection = new SqlConnection("<my connection string>"))
{
connection.Open();
}
It works perfectly fine on my Windows 7 machine, but on my other machine running Windows XP x64 the call to Open() hangs indefinitely.
Any ideas why this is happening or how I can diagnose the cause? I am running the program from an administrator account on both computers.
EDIT: Ok, it seems to be a firewall issue. I’ve connected my Windows 7 machine to the same internet connection as the Windows XP machine and now it hangs too… what ports do I need to open to let SQL traffic through, and how do I go about opening them?
EDIT: In case anyone’s interested, my network admin was blocking outgoing traffic to port 1433 out of fear of the Slammer worm …
Since I can ping and attempt to connect to database2.ehost-services.com (though I received a Login failed), let’s try to simplify your connection string:
EDIT
To answer your question regarding why your connection string did not time out, MSDN describes the
poolingattribute of the connection string as follows:So I’m thinking perhaps your connection instance wasn’t actually pooled yet to time out.
EDIT
From your error message it looks like you’re using NAMED PIPES instead of TCP/IP. Maybe this can help you out (use SQL Server Configuration Manager to select your protocol). Check under [SQL Native Client 9.0/10.0 Configuration] and you should see a list of protocols. Make sure TCP/IP is listed with an order before Named Pipes and is also ENABLED. For example, my order of 1 – 3 is Shared Memory, TCP/IP, Named Pipes, and VIA is disabled.
EDIT
Try creating an Alias with TCP/IP protocal selected and connecting to your alias? You can do this also using SQL Server Configuration Manager.
EDIT
As the OP has resolved the issue, I did make the comment on someone else’s answer:
and SOB, that’s what it was – network admin blocked outgoing traffic on port 1433. Glad you figured it out!