我正在學習官方網站的ASP.NET MVC。SQL Server連接問題(ASP.Net MVC)
當我到達this tutorial page,創建Movies控制器後,當我導航到url:localhost:// xxxx/movies/index我收到一個異常。
異常消息是:
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
我的系統細節: -
- 的Windows 10 PRO(64位)
- 社區2015年
- 的SQL Server 2014的Visual Studio (64位)
連接字符串是這樣的
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename="|DataDirectory|\aspnet-world movies-20150825083408.mdf";Initial Catalog="aspnet-world movies-20150825083408";Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="MovieDBContext" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
唯一的例外是在這個動作方法在行#20
public ActionResult Index()
Line 19: {
Line 20: return View(db.Movies.ToList());
Line 21: }
請出示與從web配置您的SQL連接字符串代碼,顯然移除所有憑證信息。 – zulq
您完成了第5步嗎? –