为了账号安全,请及时绑定邮箱和手机立即绑定

关于sql的问题急急急

关于sql的问题急急急

www说 2018-11-08 05:07:03
public bool Authenticate()  {   bool bRet = false;   string strPassword="";   //连接字符串   string strConn = System.Configuration.ConfigurationManager.AppSettings["dsn"];   //建立一个新的连接   SqlConnection cn = new SqlConnection(strConn);   //打开连接   cn.Open();//////异常提示:   //构造SQL语句字符串   string strSQL = "Select count(*) from TCustomer where CustomerName='";   strSQL += m_CustomerName;   strSQL += "'";   //构造Command对象   SqlCommand cmd = new SqlCommand(strSQL,cn);   int nCount = 0;   //执行SQL命令   nCount =(int) cmd.ExecuteScalar ();   //返回结果在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL  在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL
查看完整描述

2 回答

?
慕盖茨4494581

TA贡献1850条经验 获得超11个赞

SQL服务是否启动。

查看完整回答
反对 回复 2018-11-12
  • 2 回答
  • 0 关注
  • 302 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信