Thursday, February 9, 2012

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

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.

I am getting this error and using this connection string

Data Source=192.168.0.100;Network Library=DBMSSOCN;Initial Catalog=ENet;User ID=eonline;Password=eonline;

What can be solution for this.

you check if its firewall issue?|||see thing is that it is working gud but when my application connects to orcale and then when it come backs to connect sql it is giving error did it possible that oracle connection gives problem|||

Hi,

Since the error message contains "Could not open a connection to SQL Server", I think this error occurs when your app connects to a SQL Server. Based on the fact in your first post, have you checked if you have enabled remote connection on the server? Please following this KB article to achieve this.

http://support.microsoft.com/kb/914277/en-us

Currently, you're connecting to the database server using TCP/IP. You can also try to use Network Library=dbnmpntw to perform a named pipe connection.

|||I think I got a solution...

the error is in the connection string and in the configuration... if you'll use the IP instead of (loca), localhost, <machinename>\SQLEXPRESS, it will work. So use 127.0.0.1... the server will love it... and one more thing... at Protocols (SQL Server Configuration) at TCP/IP, set at IPAll - TCP Dymanic ports 1433 and one more... of course... set trusted connection to true... (you should allow remote connections too)..

So, the connection string is :

"Provider=SQLNCLI;Server=127.0.0.1;Database=database;Trusted_Connection=yes;"

Hope this helps someone..

P.S. : from my point of view.. I think this solution is a stupid one as long as local = localhost = 127.0.0.1... I guess for the SQLExpress... local = localhost != 127.0.0.1

No comments:

Post a Comment