SQL Server Express and VS2010 Web Application .MDF file errors
I installed SQL Server 2008 as well as SQL Server Express 2008 on my new Windows 7 development environment, along with Visual Studio 2010. I could get SQL Server 2008 to work fine, but I could not use Express .MDF databases within sample web application projects without receiving the below error:
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.
For instance, I was creating an ASP.NET Web Application. When I ran the application and tried to register a new user, I received an error:
I muddled through a lot of discouraging trials that I won't bore you with while I tried to figure out if the problem was due to the "incompatibility patch" needed with SQL Server 2008 and Windows 7, or if it was due to SQL Server Express being installed incorrectly, or VS2010 or arrrgggh! Needless to say a lot of reinstalls of numerous products were made before finding the below forum post (and the fix was so simple!):
http://forums.asp.net/t/1377174.aspx
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.
The above post suggested deleting the SQLEXPRESS directory and rebooting, which I did. Note, my path was quite different than the one recommended in the above post. I used file manager to search for "SQLEXPRESS."
C:\Users\Nannette\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
After reboot, I received an entirely different error:
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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)
One of the readers of the above post, suggested the below fix:
Go to: Control Panel -> Administrative Tools -> Services ->
right click on SQL Server (SQLEXPRESS) service then Properties -> Then Goto Logon tab -> Select the Local System Account option ->Apply->OK
Note, in my install of Windows 7, the Administrative Tools doesn't display in the Control Panel, so I had to search for "Admin" from the Control Panel to pull up the Administrative Tools icon. When I got there, my Local System Account was already setup, so that wasn't my problem.
However, by taking those steps I found the SQL Server Express was set to Automatic but was not started. So I started it.
I then went back to my web application, and I was able to open the ASPNETDB.MDF file within my VS2010 environment, and I was able to run the application and register a new user! No more errors!
[SIGNATURE]