provider: Named Pipes Provider, error: 40 – could not open a connection to SQL server.

孤人 提交于 2019-12-07 03:57:13

问题


I developed a .net application that depends on a sql server database, the database was on the local machine used for development of the application.

When I moved the database to a remote machine and changed the connection string I got the following error:


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 default settings SQL server does not allow remote connection. ( provider: Named Pipes Provider, error: 40 – could not open a connection to SQL server. )


This error occurs only from XP machines but it works fine from Win. 7 Machines with the same connection string:

connectionString="Data Source=ot;Initial Catalog=sp_warehouse;User ID=fu;Password=bar"

I tried the following to troubleshoot the problem: - Disabled Named Pipes service from the server. - Added an exception in the server firewall for the SQL Server port 1433 - Disabled the firewall on the server completely - Added this parameter in the connection string: Network Library=DBMSSOCN;Persist Security Info=True

Each time I try something I get the same result, win. 7 machines work fine but XP machines don't.

Note: There's another application works from XP machines that uses another database on the same SQL Server and it's working fine.


回答1:


Make sure the SQL Browser is enabled and running on your remote machine. You'll probably want to leave named pipes enabled.



来源:https://stackoverflow.com/questions/6897272/provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!