我創建了此MVC4 Web應用程序並使用本地MDF(localdb?)進行了操作。它位於我項目的\App_Data
文件夾中。它的名字是SiteDatabase.mdf
。將連接字符串轉換爲mdf文件
但現在我正在與連接字符串掙扎,我怎麼能「鏈接」它?
我得到這個:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=SiteDatabase;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\SiteDatabase.mdf" providerName="System.Data.SqlClient" />
凡SiteDatabase.mdf位於我App_Data
文件夾中。
錯誤即時得到:
Server Error in '/' Application.
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)
嘗試添加額外的「\」後'(的LocalDB)'.. – Milen
@Milen巴甫洛夫沒有help: -/:-( – Jason94
如何在SiteDatabase前添加'| DataDirectory | \'?http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with- ASPNET-45-web的表單/ create_the_data_access_layer – Milen