Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[ADO.NET error]: CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file HelloWorld.mdf failed

CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file C:\Documents and Settings\..\App_Data\HelloWorld.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I've found these links:

  • http://blog.benhall.me.uk/2008/03/sql-server-and-vista-create-database.html
  • http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=702726&SiteID=1
like image 268
Mark Cidade Avatar asked Aug 18 '08 16:08

Mark Cidade


3 Answers

Generally the user that you are using to run the SQL Server service will not have access to your personal user folders, that is why you're getting the error. You either need to change the credentials used for the service, or move the database to another folder, which did the trick in your case.

like image 135
baldy Avatar answered Oct 17 '22 15:10

baldy


For me helped a lot to set this tag under system.web tag on the web.config file:

<system.web>
    <identity impersonate="true" userName="admin_user" password="admin_password" />
...

Hope this can help somebody

like image 34
zanona Avatar answered Oct 17 '22 17:10

zanona


I was stuck on this today with compound issue in mvc3 and entity framework code first.

My SqlExpress install is messed up (permissions issues) so I switched to SqlCE.

My ConnectionString.Name attribute didn't match my "ProjectNameContext" class name.

When the connection string isn't found, it uses default conventions. Default conventions means my SqlExpress service with a database name like "ProjectNameContext". The permissions are messed up on that so I got a permissions error on SqlExpress when I thought I was using SqlSE

like image 2
DanielEli Avatar answered Oct 17 '22 17:10

DanielEli