سؤال

I have the following web.config file that contain the code as follows:

<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=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CustomerManagement.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" /> </connectionStrings>

However, when I run the Visual Studio Web Application project, it give me the following:

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.

Previously, it give me the following error message, which I resolve by installing the 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)

So, I was wondering which database if the error referring to. Is it referring to a database in the SQL Server or the mdf located in the project file.

(Kindly note that this project is by another person and I am trying to understand where the database is. Thank you)

هل كانت مفيدة؟

المحلول 2

In short: Make sure that your default SQL instance (mostly express version called .\SQLEXPRESS) is running on your computer. It looks like the default SQL instance is not set on your machine.

You may check it by SSMS tool. Here is a link on - SQL Server Management Studio (SSMS) Basics.

Related post on - Cannot register default instance MSSQLSERVER in SQL Server 2008

نصائح أخرى

Try deleting the contents of the following directory:

C:\Users\<user name>\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS.

(Replace the <user name> with the account that you are currently logged in to.)

For more info, see: Error: Failed to generate a user instance of SQL Server

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top