我有包含的代碼如下如下web.config文件:該代碼的數據庫應該在哪裏?
<connectionStrings> <add name="CustomerManagementConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|CustomerManagement.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" /> <add name="Entities" connectionString="metadata=res://*/App_Code.CustomerManagement.csdl|res://*/App_Code.CustomerManagement.ssdl|res://*/App_Code.CustomerManagement.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CustomerManagement.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /> </connectionStrings>
然而,當我運行Visual Studio的Web應用程序項目,它給我以下內容:
Server Error in '/CustomerManagement' Application. -------------------------------------------------------------------------------- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
以前,它給我以下錯誤消息,我通過安裝SQL Express Edition 2005來解決此問題。
Server Error in '/CustomerManagement' 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: 26 - Error Locating Server/Instance Specified) Description: An unhandled exception occurred during the execution of the current web request,. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: 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)
所以,我想知道哪個數據庫,如果錯誤指的是。它是指SQL Server中的數據庫還是位於項目文件中的mdf。
(請注意,這個項目是由其他的人,我想明白的地方數據庫,謝謝。)
實際上。\ SQLEXPRESS已經與其他SQL實例一起運行。順便說一下,如何檢查。\ SQLEXPRESS是否爲默認的SQL實例? – Jack
@Jack,我已將它發佈在我的答案上。 –