this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Friday, February 19, 2010

Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances.

You might get this error if you try to attach an mdf file resides in the data directory (App_Data folder) in websites.

This is because your sql server does not have permission to create user instance of file to be attached.

Your connection string might look like this.

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"

It can be fixed by executing following statement in the sql server, where you wish to attach.

exec sp_configure 'user instances enabled', 1

reconfigure

Restart your SQL server and try to run your application.

Note: this can be useful if you work with the local database. In most cases remote server does not allow us to run above query, you need to contact your hosting company for it.

No comments: