有这样一个连接字符串
"Server=.; Database=Northwind; Integrated Security=SSPI"
我这里使用.或我的服务器名可以正常连接
但如果这样
"server=localhost;uid=sa;pwd=;database=xx;" 
提示不能连接到字符串,什么原因,
谁给详细解释一下,分将给第一个给出正确答案的。

解决方案 »

  1.   

    "."应该类似于 "(local)",用的是named pipes,localhost一般是用TCP端口,确认你的服务器客户端开启TCP了参考
    http://weblogs.asp.net/jgalloway/archive/2005/12/02/432062.aspx同时确认C:\WINDOWS\system32\drivers\etc\hosts文件里有127.0.0.1       localhost
      

  2.   

    localhost==〉"(local)" 我上次就是这么弄得
      

  3.   

    .和local,localhost在有的時候是不一樣的含義的有的時候用local,localhost都不可以
    用.就可以
      

  4.   

    It says that when using MDAC and OLEDB, the "(local)" and "localhost" use TCP connection, but <machinename> use a shared memory connection. 
      

  5.   

    localhost并不是SQL服务器地址呀,你搞错了,local才是,你启动SQL的查询分析器的时候不是LOCAL吗,而不是localhost吧
      

  6.   

    谢谢各位的帮助,问题已经解决,我的hosts文件因上次写程序的需要而修改,导致问题的出现,