SQLEXCEPTION(0x80131904):无效的对象名称dbo.Categories“ [英] SqlException (0x80131904): Invalid object name 'dbo.Categories'

查看:1201
本文介绍了SQLEXCEPTION(0x80131904):无效的对象名称dbo.Categories“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到当我运行一个应用程序上面的例外。该应用程序是使用asp.net MVC 3 / C#。我做了一个MDF文件,并​​在Visual Web Developer中前preSS App_Data文件夹下添加它。我加了连接字符串到web.config文件夹,但是当我运行并浏览到/店,我得到的错误上面行 VAR类别= storeDB.Categories.ToList(); 突出显示。我的数据库包含6个表,其中之一是类别。

控制器:

  EventCalendarEntities storeDB =新EventCalendarEntities();公众的ActionResult指数()
{
    VAR类别= storeDB.Category.ToList();
    返回查看(类别);
}

在web.config文件中的连接字符串:

 <&是connectionStrings GT;
   <添加名称=EventCalendarEntities
        的connectionString =数据源= \\ SQLEX $ P $干燥综合征。
        集成安全性= SSPI;
        AttachDBFilename = | DataDirectory目录| \\ MvcEventCalendar.mdf;
        用户实例=真
        的providerName =System.Data.SqlClient的/>
< /&是connectionStrings GT;


解决方案

这通常只是意味着一个配置问题;


  • 也许真的有没有这样的表

  • 也许表是有的,但不是在 DBO 方案(这可能是在 Fred.Categories

  • 也许db是区分大小写的(这是罚款),和表实际上是 dbo.CATEGORIES

任何这些将引起上述异常。特别是,你的状态:


  

我的数据库包含6张桌子,其中之一是类别。


现在到的类别!= 类别

I am getting the exception above when I run an application. The application is using asp.net mvc 3 / C#. I made an mdf file and added it under App_Data folder in Visual Web Developer Express. I added connection strings to the web.config folder but when I run and browse to /store, I get the error above with the line var categories = storeDB.Categories.ToList(); highlighted. My database contains 6 tables and one of them is Category.

Controller:

EventCalendarEntities storeDB = new EventCalendarEntities();

public ActionResult Index()  
{  
    var categories = storeDB.Category.ToList();  
    return View(categories);  
}    

Connection strings in web.config file:

<connectionStrings>
   <add name="EventCalendarEntities"
        connectionString="data source=.\SQLEXPRESS;
        Integrated Security=SSPI;
        AttachDBFilename=|DataDirectory|\MvcEventCalendar.mdf;
        User Instance=true"
        providerName="System.Data.SqlClient" />
</connectionStrings>

解决方案

This usually simply means a configuration issue;

  • perhaps there genuinely is no such table
  • perhaps the table is there, but isn't the the dbo scheme (it might be in Fred.Categories)
  • perhaps the db is case-sensitive (which is fine), and the table is actually dbo.CATEGORIES

Any of these will cause the above exception. In particular, you state:

My database contains 6 tables and one of them is Category.

Now to a machine, Category != Categories

这篇关于SQLEXCEPTION(0x80131904):无效的对象名称dbo.Categories“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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