provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server解决办法

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

 

Server Error in '/' Application.


A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

 

 

在配置完网站时,打开网站提示错误,provider: 命名管道提供程序, error:provider命名管道提供程序,error:40无法打开到SQL Server的链接。

在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error:40 - 无法打开到 SQL Server 的连接)
我是现装了SQL Server2000 后 在装SQL Server2005的,网上有很多解决方法!
下面一一列举下:
1, 在开始菜单,程序里面的 SQL Server2005下有个SQL Server2005外围程序配置器 选择服务和连接的外围配置器,在database engine里选择远程控制,把本地连接和远程连接改成同时使用TCP/IP和named pipes!保存.关闭数据库服务器链接,重新链接!

2,配置文件web.config里面的数据库连接字符串里面的Data Source用本地服务器名字,不要用Ip或者loacl或者.
例:<add key="Statdb.Connectstring" value ="Data Source=MICROSOF-9D13DF;Initial Catalog=Users;User ID=sa;Password=SA"/>
3,IIS配置里面删除默认的数据库链接字符串,因为装了SQL Server2005后,默认连接是2005
我的电脑,管理,iis配置里面的默认网站,右键查看属性,asp.net版本选择你使用的版本,然后把编辑配置和编辑全局配置里面的默认的字符串链接删除!
 

修改编辑全局配置和编辑配置

红圈部分原来有默认的数据库连接字符串的,把它移除!
4,打SQL Server补丁
在查看数据库日志的时候,发现了这样的提示!
您 运行的 Microsoft SQL Server 2000 版本或 Microsoft SQL Server 2000 Desktop Engine (也称为 MSDE) 和 Microsoft Windows Server 2003 家族使用时存在已知的 安全弱点。为了减少计算机被某些病毒的攻击,Microsoft SQL Server 2000,MSDE 或 两者的 TCP/IP 和 UDP 网络端口被禁用。要启用这些端口,您必须从 http://www.microsoft.com/sql/downloads/default.asphttp://www.microsoft.com/china/sql/downloads/default.asp 安装一个修补程序, 或 Microsoft SQL Server 2000 或 MSDE 的最新服务包。
下载补丁,打上!
5,修改SQL Server2000的远程连接端口
在现装了SQL Server2000后装SQL Server2005的时候,后者会把前者的远程连接端口修改了,原先的端口为1433。在我查看的时候果然被改成1058端口了
把它改过来,改成1433即可!
开始菜单,程序里面的SQL Server2000下有个服务器网络使用工具。选择TCP/IP然后点击属性编辑它的端口

选择TCP/IP修改其属性

把默认端口设置为1433
总结,因为,我遇到了这样的问题,找了很久解决方法,用修改端口的方法解决了数据库链接的问题,希望总结的几个方法能对大家有用!

posted @ 2015-10-27 11:29  tiger5  阅读(11888)  评论(0编辑  收藏  举报