The problem that the create database permission is denied in the database 'master'

Source: Internet
Author: User

Today, we use LINQ to SQL to determine whether a database exists. If no database exists, it is automatically created.

Public partial class cms_dbdatacontext
{
Partial void oncreated ()
{
// Create a database if the database does not exist
If (! This. databaseexists ())
{
This. createdatabase ();
}
}
}

The following error occurs: the create database permission is denied in the 'master' database.

After reading the relevant information, we know that to run the SQL Server database, you must create a database under the instance. Whether it is directly created, appended, or restored, you must create a database under the instance.

Therefore, modify the connection string,

<Add name = "se_dbconnectionstring" connectionstring = "Data Source =. \ sqlexpress; initial catalog = se_db; Integrated Security = true; pooling = false; user instance = true "providername =" system. data. sqlclient "/>

After adding user instance = true, you can use the instance to successfully create a database.

Solution 2:

Assign the database administrator role to the user who logs on to the database. This error can also be solved. For example, in ASP. NET, a network service user accesses the database and can set the database role of this user as the database administrator. In short, ensure that the login user has the right to create, modify or delete the database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.