2011-12-23 72 views
0

我正在用C#应用程序部署我的数据库,但当我在另一台机器上安装setup.exe文件时,我无法连接到数据库。C#和SQL Server部署问题

我得到的错误是:

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 connection.(provider:Named pipes Provider,error:40- could not open a connection to SQL Server)

我应该怎么做才能解决这个?

+0

你的连接字符串是什么?这听起来像你不能正确地击中'servername [\ instancename]'。 – 2011-12-23 14:38:15

+2

什么代码用于连接? SQL远程? – bryanmac 2011-12-23 14:39:06

+1

上次我有一个“命名管道提供商错误”,这是一个防火墙问题(允许TCP连接的SQL Server的规则丢失)。 当SQL Server无法使用默认的TCP提供程序时,它会尝试使用命名管道。 – ken2k 2011-12-23 14:43:37

回答

1

这可能是多种原因。最有可能...连接字符串不正确(最有可能),或者您尝试连接的实例没有启用命名管道。

要检查后一个进入程序 - > SQL服务器{版本} - >配置工具 - > SqlServer的配置管理器 - >找到客户端协议,然后找到命名管道/ TCP/IP,并将其设置为Enabled