错误信息:
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)
检查后发现是webconfig的配置问题,将
<add key="ConnectionString" value="Data Source=(local);Initial Catalog=my51aspx;User ID=sa;Password=sa;"/>,
改成本地计算机名
<add key="ConnectionString" value="Data Source=(liuranjun\data);Initial Catalog=my51aspx;User ID=sa;Password=sa;"/>,
问题解决。
在SQL 里:
Server=(local); 用的是named pipes 通讯.
Server=localhost; 用的是从 port 1434 udp协商来的端口,缺省是1433的口上进行TCP通讯.
我听人说过,Server=localhost在XP Service Pack 2 以前还工作,到了XP SP2就不工作了.
MS建议用server=计算机名,不用Server=localhost