2014-10-12 69 views
0

我有一個數據庫,名爲Library,在我本地創建的服務器實例下創建於SQL Server 2014中。我在Windows窗體應用程序中使用該數據庫作爲數據源。這是完全工作時,我的電腦,但是當我在其他機器上運行它,它與使用C#應用程序對使用SQL Server 2014創建的數據庫進行遠程訪問Management Studio

Unhandled exception occurred...

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 connection to SQL Server)

我已經開始從配置管理器中的所有服務,並在協議已經啓用了TCP/IP協議爲MSSQLSERVER錯誤停止。有什麼辦法可以做到這一點,還是我必須轉移到本地數據庫?

回答

1

確保您的連接字符串包含您的遠程計算機的名稱爲「數據源」的一部分,所以是這樣的: 的connectionString =「數據源=計算機名\的SQLExpress;初始目錄= mydbname;集成安全性=真」

請注意,此連接字符串將在具有SQL Express實例的計算機machinename下面以db名稱「mydbname」爲目標。

如果沒有工作,讓我看看你的連接字符串。

+0

您能否詳細說明您所說的「配置字符串」?我的連接字符串是: 'Data Source = NILADRI-HP; Initial Catalog = BookLibrary; Integrated Security = True; Encrypt = False' – Nil 2014-10-12 11:54:16

+0

您好無,我的意思是連接字符串,現在查找您的連接字符串,您正在使用您的Windows憑據可以訪問遠程數據庫,因此請確保使用您的Windows用戶名/密碼,您可以連接到NILADRI-HP,並通過SQL Management Studio完全訪問「BookLibrary」數據庫,如果您不需要連接例如在NILADRI機器上使用用戶名/密碼設置,具有對BookLibrary數據庫的讀/寫訪問權限。 – 2014-10-13 12:37:00

相關問題