View Single Post
  #1 (permalink)  
Old November 7th, 2009, 11:39 PM
HungryCaterpillar HungryCaterpillar is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 18: Getting "Failed to generate a user instance of SQL Server" error

I was able to get my begASPNET/Release site to work under IIS, as described in the book, but I get variants of the following error every time I access the database (Reviews>By Genre, Gig Pics, upon login, etc.):

Code:
Server Error in '/' 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.

Source Error: 

Line 23: 
Line 24:             Repeater1.DataSource = allGenres;
Line 25:             Repeater1.DataBind();
Line 26:         }
Line 27:     }
 

Source File: c:\begASPNET\Release\Reviews\AllByGenre.aspx.cs    Line: 25 

Stack Trace: 

[SqlException (0x80131904): 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.]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4845255
...
My connection string is:
Code:
<connectionStrings>
		<add name="PlanetWroxConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\PlanetWrox.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
	</connectionStrings>
I'm running Windows XP and using SQL Express for the PlanetWrox database, but I also have SQL Server 2005 installed. I'm using the Professional Edition version of Visual Studio 2008.

I did the file system setup steps described in the "Configuring the File System" Try It Out. I also Googled the error message and found some instructions about running sp_configure 'user instances enabled' 1 in SQL Server Mgmt Studio and deleting the Microsoft SQL Server Data\SQLEXPRESS directory, but to no avail.

One thing I noticed was that the \SQLEXPRESS directory is created and populated with: master.mdf, mastlog.ldf, msdbdata.mdf, and msdblog.ldf when I try to access the database (in c:\Documents and Settings\ASPNET\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS). So something does seem to be at least partially working.

Any thoughts or suggestions on what else to try would be appreciated. I can't really tell from the error message what's actually failing or what kind of thing needs to be corrected.


Thanks,

Geoff
Reply With Quote