我有包含的代码如下如下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,我已将它发布在我的答案上。 –