Wednesday, October 31, 2012

Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

I started getting this error on one of the applications that I had created.The application was a wcf restful service that was hosted on IIS making a database call.For reasons that I could not understand I started getting this error and it was evident that the owner of the server had tweaked the settings on the database server.

After searching the cause and making sure all the steps listed in the this blog (http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/) were correct, I was still not able to resolve the issue.

So I came up with a workaround.I changed the default protocol in the connection string and Voila!!! it works now without any issues
Here is the previous and current connection strings


<add name="Production" connectionString="Persist Security Info=False;User ID=username;Password=password;Initial Catalog=databasename;Data Source=servername" />

<add name="Production" connectionString="Persist Security Info=False;User ID=username;Password=password;Initial Catalog=databasename;Data Source=tcp:servername,1434" />

*Note that owner of the server was using 1434 port number for tcp protocol.

Hope it helps !!!


No comments: