Data Source=localhost 或者=127.0.0.1为什么都连接不到数据库?只有=.的时候可以,我用的是SQL2008

Data Source=localhost/实例名 可以连接.但是用ip不行...因为我想局域网内都可以连接到我的数据库

你是不是TCP/IP协议那里没有启用啊
要启用了才能通过127.0.0.1此类的进行连接追问

TCP/IP协议启用了

追答

你用的是不是win7啊 或者你的host文件是不是有修改过关于local的指向

追问

系统是win7的、这是hosts里面的
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

追答

win7里我也遇到过这个问题
最后我是用::1连接的
或者把# ::1 localhost里的#去掉也可以用localhost

追问

还是操作数据库出错

追答

数据库出错和连接就无关了吧,你安装的时候有问题还是什么。你自己能不能用企业管理器管理数据库啊

追问

但是我用Data Source=.;就可以连接啊

追答

你先确认下能不能在本机用企业管理器管理数据库。如果不行 要考虑安装的问题
其实能用什么方式连接就用什么方式没必要刻意要用localhost

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-06-25
你 hosts 文件没有定义

[C:\WINDOWS\system32\drivers\etc]type hosts

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost

[C:\WINDOWS\system32\drivers\etc]
追问

改成和你一样后、还是不能通过127.0.0.1链接数据库

第2个回答  2011-06-24
DNS没解析吧,用local

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网