使用.net2005连接到本地SQL Server2005

来源:百度知道 编辑:UC知道 时间:2024/09/20 03:01:31
使用C#在.net2005下新建database
使用localhost的servername
但是总是失败
错误信息:
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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
输入本机IP地址,或者local都是同样错误
TCP/IP的端口是1433
是这个端口吗?最后servername里输机器名\sqlexpress
ok了

如果是本机:不要用服务名,也不要用localhsot,用IP地址:127.0.0.1

SQL 2005的端口开了么?用其它电脑,telnet到1433端口能上吗?(SQL 2000是1433,SQL 2005没看过端口,应该也是1433)

在另一台机的命令行模式下:telnet 你sql2005机的IP 1433
如果能连上说明端口开了。如果不能连接,说明端口关了。
你可到微软网站上看看,如何开。