只为成功找方向,不为失败找借口

每天都不能停止前进的脚步
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

数据库连接字符串的一个问题

Posted on 2009-01-04 18:39  冰碟  阅读(164)  评论(0编辑  收藏  举报

错误信息:

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