2011-12-23 70 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