Tuesday, June 12, 2007

Could not open a connection to SQL Server

Using Visual Studio 2005 I tried to connect to a fresh installation of SQL Server 2005 Express. I encountered the following problem:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I tried all the suggestions such as the ones provided by DataMasker but had no luck. But then I found a hint in a discussion forum on DevX that helped me to resolve the issue. Instead of entering just "localhost" for the Server name I used "localhost\SQLExpress" and all the sudden it worked.
With this blog entry I hope that I can save some people's time. Cheers!

4 comments:

Anonymous said...

Hey, thanks for the info, I had been trying for about 30 minutes on this one wondering why it wouldn't work. It kept connecting to the PinnacleSys instance of SQL Server, and would not recognize SQLExpress until I added localhost\SQLExpress, then it worked like a charm.

Anonymous said...

This could also happen if you specify -s instead of -S i.e. you use small letter for the server directive. Similar error is shown ...

Unknown said...

Thank you sir!

TwIsTuD™ said...

amazing! thanks a LOT!!! i was trying to test the local host! but why does it come this way!? i mean isnt it supposed to be localhost!?????

Post a Comment

All comments, questions and other feedback is much appreciated. Thank you!