locked
Can't create database RRS feed

  • Question

  • On my latest SQL Express install, I can't seem to be able to grant a user permissions to create databases.

    I tried first with the 'sa' account (and later with creating new users). In management studio I can create DB's with all the users i try, but from a webpage in IIS i get the following:

    "CREATE DATABASE permission denied in database 'master'."

    But this is not true. The user definitely has the permissions needed. But the database simply won't be created (this is though EntityFramework - Code first).

    Also there should not be anything wrong with the code that creates the DB, as it works just fine in the test environment.

    Looks like IIS is exchanging my user for another IIS user. How can I stop this? Can't find any such settings in IIS (and manipulating the "connection strings" property in IIS does not seem to help).

    And yes, i have tried:

    Trusted_Connection=False;

    Integrated_Security=False;


    • Edited by JustinCase Tuesday, February 5, 2019 1:09 PM
    Tuesday, February 5, 2019 12:41 PM

All replies

  • Hi,

    It is NOT a good idea to create database in your application. Why can't you create it before running the application?

    Try to put this
    	<connectionStrings>
    		<add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
    	</connectionStrings>
    


    within Web.config/app.config file in your project, to ensure the project will work fine with the database.


    Many Thanks & Best Regards, Hua Min

    Tuesday, February 5, 2019 12:52 PM
  • Thanks for your answer.

    I COULD of course do that, but it would solve nothing. The user is not even allowed to log in to the database. The problem is that is doesn't use the user i specified, but some IIS app pool user instead.

    Figured this out though:
    Had to set the app pool to use "Netwrok Service", then give the network service account the needed permissions on DB. After that, everything works.

    Doesn't seem like the correct solution though. I WANT to use the connection string specified user for the DB. Still, it works for now and that's all I care about ATM. :)

    Tuesday, February 5, 2019 1:53 PM
  • Lookup Default Connection string Settings in IIS to seee what's there defined: Configuring Step 3: Configure Data Source Settings

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Tuesday, February 5, 2019 2:09 PM