Microsoft SQL Server Express Remote Connection
I am using my office PC remotely from home by using a remote desktop connection. I just had a problem today connecting to the SQL Server Express database from Visual Studio 2008.
In the SQL Server Management Studio Express I was able to connect to the database, however from within Visual Studio I got the following 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'
I found out that making a new project and adding a new database to this new project gave the same error.
After some research I found out that it's a known bug in Windows XP SP2:
You cannot connect to Visual Studio SQL Server Express on a remote Windows XP Service Pack 2-based computer.
http://support.microsoft.com/?id=896613
The cause of this problem is that you're in a different session than SQL Server Express when you're remotely logged in.
In my SQL Server Express error log (located in the following folder: C:\Documents and Settings\[User Account]\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS), I noticed the error occurred after I disconnected (logged of) from my remote computer.
There's a hotfix for this problem, but I didn't install it, I just remotely restarted my computer by clicking: 'Start' and then 'Run' and typing:
shutdown -r
This will enable you to restart your computer from within a RDP session. You have to wait for 30 seconds before the computer reboots.
In case you want an immediate restart, just type:
shutdown -r -t 01
By the way, you can also shut down your computer remotely:
shutdown -s -t 01
It's also possible to remotely restart your PC in case you have VNC installed. Just connect via VNC to your remote computer and restart your computer like you're used to.
After the restart, the problem was gone.