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:
Post a Comment