2012-01-27 180 views
-1

我正在使用Visual Studio並嘗試連接到Northwind數據庫。我用下面的連接命令連接到SQL數據庫

Data Source=C:\\Program Files (x86)\\Microsoft SQL Server Compact Edition\\v3.5\\Samples\\Northwind.sdf;Initial Catalog=Northwind;Integrated Security=SSPI" 

我也曾嘗試

Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI 

這兩種情況下我得到一個錯誤 -

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

我可以連接到一個在線數據庫,但不在遙遠的一個。我已經檢查過配置管理器,所有的服務都在運行。

任何幫助,請

+1

什麼數據庫你試圖連接到,你的第一個連接字符串是SQL Server CE(精簡版)。您是否嘗試過Connectionstrings.com http://www.connectionstrings.com/ – Lloyd 2012-01-27 10:00:33

+0

您是否檢查過數據庫實際上正在運行,並且它允許您發送的用戶/憑證的連接? – Purplegoldfish 2012-01-27 10:21:53

回答

0

有很多連接字符串的集合,所以你可以從這裏得到幫助......

http://www.connectionstrings.com/sql-server-2008

+0

謝謝,但是我在嘗試什麼? – 2012-01-27 10:01:48

+0

使用正確的SQL Server實例名稱,如果您使用的是MDF文件路徑,請將該文件放入App_Data文件夾中,因爲Program Files文件夾是受限文件夾,IIS在虛擬目錄中正常工作... – 2012-01-27 10:09:25

0

在Visual Studio有工具連接到數據庫。使用服務器資源管理器,您可以選擇要連接的SQL Server,然後從列表中選擇數據庫。一旦你成功連接到一個,它的屬性會提到要使用的連接字符串。無需猜測。