none
CREATE DATABASE permission denied in database 'master'

    Question

  • I am having a strange problem. I have a web application and it is fetching data from Northwind database which is downloaded and attached to sql express 2008. When I execute the web application from VS2008 it is working fine. But when I publish the website and browse from there I am getting a permission error, as follows.

    CREATE DATABASE permission denied in database 'master'.
    Cannot attach the file 'D:\SQL Server 2000 Sample Databases\NORTHWIND.MDF' as database 'Northwindd'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.
    Cannot attach the file 'D:\SQL Server 2000 Sample Databases\NORTHWIND.MDF' as database 'Northwindd'.

    I dont understand why is this happening. I gave permission to Northwind.MDF for 'Everyone', even then its not working.

    Monday, June 01, 2009 12:24 PM

All replies

  • Your web app user needs to have dbcreator rights.  Alternatively, just attach the database and leave it attached - user instances aren't around for the long haul anyway, so you may as well pull the user instance code out now, while you're working on it.
    Aaron Alton | thehobt.blogspot.com
    Tuesday, June 02, 2009 5:36 AM
  • Hi Aaron Alton,

     

    I am using vs2010 and sql server express.

    I attached a Test.mdf database in the sql server management studio and have a alias name as NewCC.  

    I host wcf service in iis.

    When I do WcfTestClient I got the same error:

    "CREATE DATABASE permission denied in database 'master'.
    Cannot attach the file 'D:\DotNet\Data\Test.mdf' as database 'NewCC'."

    I believed your reply solved Dileep's problem. But I just don't know how do "Your web app user needs to have dbcreator rights".  what is the user in my case? how to find the user name?

    attach the database and leave it attached ? You mean attched db by using sql server management studio ?

    Thanks.

     

    Tuesday, November 08, 2011 5:15 AM