User permission error when accessing "user instance" database from ASP.NET User permission error when accessing "user instance" database from ASP.NET asp.net asp.net

User permission error when accessing "user instance" database from ASP.NET


Does the child instance even start? When a RANU database is requested the master instance (.\SQLEXPRESS in this case) has to create a 'child' instance, in other words start the sqlservr.exe process as an user process running under the credentials of the user that requested the RANU connection from the .SQLEXPRESS instance. In this case the instance would have to be started as 'NETWORK SERVICE'.

To validate if the child instance is started, connect to the master instance (.\SQLEXPRESS) and check sys.dm_os_child_instances:

SELECT * FROM sys.dm_os_child_instances

If an NETWORK SERVICE owned child instance is started, take it's instance_pipe_name and connect straight to the child instance:

sqlcmd -S np:\\.\pipe\<child pipe name>\tsql\query

Ideally, connect as NETWORK SERVICE (eg. from an interactive cmd console started as NEWTORK SERVICE, perhaps using at.exe to schedule it 1 minute in future). If that works, the last step is to try to attach the MDF using ordinarry sp_attach_db.

The idea of these steps is not to solve the issue, but pinpoint the failure cause, since the error you get is kinda generic and ... not exactly helpfull.


This question appears related to: "Cannot open user default database. Login failed." after installing SQL Server Management Studio Express

Apparently User Instance and SQL Server Express has some interesting issues. You might want to take a look at http://blogs.msdn.com/b/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-instances-in-management-studio.aspx. This seems to do the trick for most who have this problem.


Integrated Security=True

Is the user logon(s) in the database connected to user accounts in the machine? Could it be that there is some mapping issue around that?