0

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)

Jack
  • 1,603
  • 5
  • 25
  • 36

2 Answers2

1

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

Community
  • 1
  • 1
d.moncada
  • 16,900
  • 5
  • 53
  • 82
  • Thanks moncadad, it give me another error - `The database 'D:\LABFILES\APP_DATA\CUSTOMERMANAGEMENT.MDF' cannot be opened because it is version 655. This server supports version 611 and earlier. A downgrade path is not supported. Could not open new database 'D:\LABFILES\APP_DATA\CUSTOMERMANAGEMENT.MDF'. CREATE DATABASE is aborted. An attempt to attach an auto-named database for file D:\LABFILES\APP_DATA\CustomerManagement.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.` – Jack Jan 03 '13 at 02:57
  • It looks like it might be a a SQL Server 2005 and 2008 compatibility issue. Try deleting the .MDF and .LDF files from the App_Data folder. They should get re-created after re-compiling. ** Make sure you back up your MDF file first!! ** – d.moncada Jan 03 '13 at 02:59
  • By the way, I don't get it why this that `C:\Users\\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS` folder was there. Is there a purpose for that folder to be there? – Jack Jan 03 '13 at 02:59
  • Thanks moncadad, but it seems that I cannot find the two files `ASPNETDB.MDF` and `aspnetdb_log.ldf` files from the App_Data folder. – Jack Jan 03 '13 at 03:03
  • @Jack sorry, that was a copy/paste error. Your files will be different. Try deleting the .MDF and . LDF files in that directory (regardless of names) See my revised comment. – d.moncada Jan 03 '13 at 03:04
0

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

Community
  • 1
  • 1
Yusubov
  • 5,815
  • 9
  • 32
  • 69
  • Actually the .\SQLEXPRESS is already running together with other SQL instance. By the way, how do I check if the .\SQLEXPRESS is the `default` SQL instance? – Jack Jan 03 '13 at 03:05
  • @Jack, i have posted it on my answer. – Yusubov Jan 03 '13 at 03:09