5

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.

Anybody ever get this error and/or have any idea on it's cause and/or solution?

This link may have relevant information.

Update

The connection string is =.\SQLEXPRESS;AttachDbFilename=C:\temp\HelloWorldTest.mdf;Integrated Security=True

The suggested User Instance=false worked.

0

6 Answers 6

11

Here is the answer to your problem:

Very often old user instance creates some temp files that prevent a new SQL Express user instance to be created. When those files are deleted everything start working properly.

First of all confirm that user instances are enabled by running the following SQL in SQL Server Management Studio:

exec sp_configure 'user instances enabled', 1.
GO
Reconfigure

After running the query restart your SQL Server instance. Now delete the following folder:

C:\Documents and Settings\{YOUR_USERNAME}\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\{SQL_INSTANCE_NAME}

Make sure that you replace {YOUR_USERNAME} and {SQL_INSTANCE_NAME} with the appropriate names.

Source: Fix error "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance."

Sign up to request clarification or add additional context in comments.

3 Comments

Great this solved mine too, but the path for windows 7 is better explained here: social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/…
Hi, thank you so much. this has solved my error too. :)
I must have copied the folder over from a recent restore to a new drive (manually copying settings back, etc.). Removing it indeed did the trick. Is this mainly a cache directory?
3

You should add an explicit User Instance=true/false to your connection string

Comments

0

I started getting this error this morning in a test deployment environment. I was using SQL Server Express 2008 and the error I was getting was

"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."

Unsure about what caused it, I followed the instructions in this post and in other post about deleting the "C:\Users\UserName\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS" directory, but to no avail.

What did the trick for me was to change the connection string from

"Data Source=.\SQLExpress;Initial Catalog=DBFilePath;Integrated Security=SSPI;MultipleActiveResultSets=true"

to

"Data Source=.\SQLExpress;Initial Catalog=DBName;Integrated Security=SSPI;MultipleActiveResultSets=true"

Comments

0

I followed all these steps but also had to go into

  1. Control Panel > Administrative Tools > Services
  2. Right-click on SQL Server (SQLEXPRESS)
  3. Select the Log On tab
  4. Select the Local System account and then click OK

Problem solved... thank you

2 Comments

This should be a comment or should be more complete. You followed all steps of what?
Apologies... this was my first post... For clarity I followed steps provided by Roboblob and also the steps listed in my post. But yes, this should have been put as a comment in the post in question.
0

I have windows 8 and I test the solution

  1. Enable user instances
    exec sp_configure 'user instances enabled', 1.
    GO
    Reconfigure

  2. Restart your SQL Server instance.

  3. Delete the folder: C:\Users\Arabic\{YOUR_USERNAME}\Local\Microsoft\Microsoft SQL Server Data
    Replace {YOUR_USERNAME} with the appropriate names.

the source from Roboblob

Comments

0

Please note that I found Jon Limjap's answer helpful except that after I did more research I found that it only applies to database connection strings that contain AttachDBFilename, so I had to change my connection string in web.config from:

connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf"

To:

connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"

For details please see If add [user instances=true] to connection string, an exception is thrown

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.