2011-01-27 147 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服務器屬性對話框,在左側窗格中去連接,並檢查「允許遠程連接到此服務器「