本文介绍了无法创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我最新的SQL Express安装中,我似乎无法授予用户创建数据库的权限。

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

我首先尝试使用'sa'帐户(以及稍后创建新用户)。在管理工作室中,我可以与我尝试的所有用户一起创建数据库,但是从IIS中的网页我得到以下内容:

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:

"在数据库'master'中拒绝CREATE DATABASE权限。"

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

但事实并非如此。用户肯定拥有所需的权限。但是数据库根本就不会被创建(这虽然是EntityFramework - 代码优先)。

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.

看起来IIS正在为另一个IIS用户交换我的用户。我怎么能阻止这个?在IIS中找不到任何此类设置(并且在IIS中操作"连接字符串"属性似乎没有帮助。)

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).

是的,我尝试过:

Trusted_Connection = False;

Trusted_Connection=False;

Integrated_Security = False;

Integrated_Security=False;

推荐答案

在您的应用程序中创建数据库并不是一个好主意。为什么不能在运行应用程序之前创建它?

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

	<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.


这篇关于无法创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 01:12