“CREATE TABLE权限在数据库中被拒绝”中的列表表结果ASP.NET - MVC4 [英] Listing table results in "CREATE TABLE permission denied in database" ASP.NET - MVC4

查看:1159
本文介绍了“CREATE TABLE权限在数据库中被拒绝”中的列表表结果ASP.NET - MVC4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET MVC 4 - c#连接到实时数据库,并列出结果,但是当我去查看该页面时,它返回以下错误:

 在数据库DatabaseName中拒绝CREATE TABLE权限。 

说明:执行期间发生未处理的异常
当前Web请求。请查看堆栈跟踪以了解更多关于错误的
信息,以及
在代码中的位置。



异常详细信息:System.Data.SqlClient.SqlException:CREATE TABLE
在数据库'DatabaseName'中拒绝的权限。

源错误:


行16:public ActionResult Index()
行17:{
行18:return View .AccControls.ToList());
第19行:}
第20行

控制器:

 命名空间TestDBCon.Controllers 
{
public class HomeController:Controller
{
private DataDbContext db = new DataDbContext();

public ActionResult Index()
{
return View(db.AccControls.ToList());
}

}
}

AccControl。 cs(model)

 命名空间TestDBCon.Models 
{
public class AccControl
{
public int ID {get;组; }
public int ControlCode {get;组; }
public string Nominal {get;组; }
public string CostCentre {get;组; }
public string Department {get;组; }
}

public class DataDbContext:DbContext
{
public DbSet< AccControl> AccControls {get;组; }
}
}

Web.Config:

 < add name =DataDbContextconnectionString =Data Source = ***; initial catalog = ***; integrated security = True; providerName =System.Data.SqlClient/> 

我没有尝试创建表?我只是想列出结果,所以我非常困惑。



谢谢

你的 web配置是否指向正确的数据库?p>

解决方案



凭证是否正确?



如果要使用 MVC4 WebSecutiy()来处理用户的认证和授权。这可能是抛出异常。



在这种情况下,您无法创建成员资格提供程序所需的表,您需要将其从系统中排除。查看此此处。或者创建一个新的MVC4项目,并选择空模板,只是把所需的位。


I'm using ASP.NET MVC 4 - c# to connect to a live database, and list the results, however when I go to view the page it returns the following error:

CREATE TABLE permission denied in database 'DatabaseName'.

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 TABLE
permission denied in database 'DatabaseName'.

Source Error: 


Line 16:         public ActionResult Index()
Line 17:         {
Line 18:             return View(db.AccControls.ToList());
Line 19:         }
Line 20

Controller:

namespace TestDBCon.Controllers
{
    public class HomeController : Controller
    {
        private DataDbContext db = new DataDbContext();

        public ActionResult Index()
        {
            return View(db.AccControls.ToList());
        }

    }
}

AccControl.cs (model)

namespace TestDBCon.Models
{
    public class AccControl
    {
        public int ID { get; set; }
        public int ControlCode { get; set; }
        public string Nominal { get; set; }
        public string CostCentre { get; set; }
        public string Department { get; set; }
    }

    public class DataDbContext : DbContext
    {
        public DbSet<AccControl> AccControls { get; set; }
    }
}

Web.Config:

<add name="DataDbContext" connectionString="Data Source=***;initial catalog=***;integrated security=True;" providerName="System.Data.SqlClient" />

I'm not trying to create a table? I'm just trying to list results so I'm extremely confused. It must be something to do with the MVC?

Any help would be greatly appreciated!

Thanks

解决方案

Is your web config pointing to the correct database?

Are the credentials correct?

Entity Framework will create tables in the database if you are going to use the MVC4 WebSecutiy() to handle the Authentication and Authorisation of users. This could be throwing the exception.

In this case where you cannot create the tables needed for the membership provider, you will need to exclude this from the system. See this here. Alternatively create a new MVC4 project and select empty template and just put in the bits you need.

这篇关于“CREATE TABLE权限在数据库中被拒绝”中的列表表结果ASP.NET - MVC4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆