2011-01-27 148 views
0

当我尝试运行我的项目,我得到follwing错误消息无法连接数据库

Message : Message : Message : Message : Message : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

我跟我的本地数据库和数据库服务器都尝试,得到同样的错误。 但是当我将它上传到我的测试网站时,它在那里工作。当我运行我的另一个项目时,他们的工作正常。 请告诉我我需要做什么在我的本地机器上运行。

+2

添加ConnectionString(空白输出用户名和密码)和其他SQL特定信息,例如SQL Server的名称,实例名称等。 – tomasmcguinness 2011-01-27 11:37:03

+0

相同的Connectionstring在服务器上工作,为什么不能在本地机器上工作? – Vijjendra 2011-01-27 11:58:37

回答

1

确保满足以下条件,

  1. SQL Server应是启动和运行。 转至所有程序>> Microsoft SQL Server 2008 >>配置工具>> SQL Server配置管理器>> SQL Server服务,并检查SQL Server服务状态是否为“正在运行”

  2. 在SQL Server中启用TCP/IP配置 转至所有程序>> Microsoft SQL Server 2008 >>配置工具>> SQL Server配置管理器>>选择TCP/IP。右键单击TCP/IP >>点击启用

  3. 启用远程连接 在SQLSERVER,右键单击服务器节点并选择Properties.In服务器属性对话框,在左侧窗格中去连接,并检查“允许远程连接到此服务器“