2017-05-06 141 views
1

enter image description here不能從SQL Server 2012的

得到的數據。當我嘗試登錄到我的網站,就會發生錯誤。我也嘗試過運行SQL服務。

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)

連接字符串

Data Source=.\SQLEXPRESS (metro);Initial Catalog=metrodb;Integrated Security=True 
+0

你可以請張貼你正在使用的**連接字符串**嗎?該錯誤基本上說,該連接字符串有問題..... –

+0

我已更新我的問題與連接字符串。 –

回答

1

根據您的連接字符串,你試圖連接到SQL Server 快速例如被稱爲SQLEXPRESS (metro) - 是真的實際名稱你的實例?

通常情況下,如果你不改變任何違約,它只是SQLEXPRESS,因此您的連接字符串應該是

Data Source=.\SQLEXPRESS;Initial Catalog=metrodb;Integrated Security=True 

你可以看到你(和他們叫什麼)什麼SQL Server實例,當你去Start > Microsoft SQL Server > SQL Server xxxx > Configuration Tools > SQL Server Configuration Manager - 你會看到這樣的事情:

enter image description here

你應該看到這是啓動至少一個SQL Server (instance name)服務 - 括號中的名字我s您的實例名稱(而MSSQLSERVER指的是默認的未命名實例)。那麼這在你的案例中顯示了什麼?

+0

是的..我已經使用連接名稱,而不是服務器名稱connectionString。謝謝 ! –