如何解决sql连接错误HResult 0x2, Level 16, State 1 Could not open a connection to SQL Server [2].

来源:互联网 发布:获取数据索引 编辑:程序博客网 时间:2024/06/01 18:50

HResult 0x2, Level 16, State 1

Named Pipes Provider: Could not open a connection to SQL Server [2].

Error: Microsoft SQL Native Client : 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..

Error: Microsoft SQL Native Client : Login timeout expired.

在使用 sqlcmd试图连接本机数据库的时候出现以上错误,已经检查了以下情况:

1. sqlserver服务已开启

2. sqlserver browser已开启

3. TCP/IP 和 Named Pipes protocol 均开启

4. sql area configuration允许本地和远程连接

5. 防火墙1433端口准许连接

修改设置后已经重启sql服务,仍然得到以上错误

这个时候您需要检查服务端口设置了,默认端口均是0,你需要把默认端口改成可用的值(默认1433 和防火墙设置一致),保存后重启服务,问题解决。



原创粉丝点击