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.
Data. SqlClient. SqlException (0x80131904): A network-related or instance-specific error occurred while extablishing 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.
SqlClient) Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database.
A SqlConnection object represents a unique session to a SQL Server data source. With a client/server database system, it is equivalent to a network connection to the server. SqlConnection is used together with SqlDataAdapter and SqlCommand to increase performance when connecting to a Microsoft SQL Server database.
SqlException (0x80131904): Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.
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."
You should add an explicit User Instance=true/false to your connection string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With