Microsoft Office Access数据库引擎找不到输入表或查询“Mobile”。确保它存在并且其名称拼写正确 [英] The Microsoft Office Access database engine cannot find the input table or query 'Mobile'. Make sure it exists and that its name is spelled correctly

查看:775
本文介绍了Microsoft Office Access数据库引擎找不到输入表或查询“Mobile”。确保它存在并且其名称拼写正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我使用VS 2012,MS Office 2013,我不知道如何在c#程序中解决这个错误?

System.Data.dll中出现未处理的System.Data.OleDb.OleDbException类型异常

附加信息:Microsoft Office Access数据库引擎无法找到输入表或查询'Mobile'。确保它存在并且其名称拼写正确。

你能帮助我吗?

我想在访问2013中连接数据库。我的代码在这里:



Hi!
Iam using VS 2012, MS office 2013, i don't know how to solve this error in c# program?
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: The Microsoft Office Access database engine cannot find the input table or query 'Mobile'. Make sure it exists and that its name is spelled correctly.
Can you help me!
I want to connect the database in access 2013. My code here:

public class Mobile
    {
        public string MId { set; get; }
        public string MName { set; get; }
        public string MProducer { set; get; }
        public int MProductYear { set; get; }
        public float MCost { set; get; }
    }










public BindingList<Mobile> GetAll()
        {
            BindingList<Mobile> list = new BindingList<Mobile>();

            string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MobileList.accdb;";
            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                connection.Open();

                string sql = "select * from Mobile"; // Mid, MName, Mproducer, MProductionYear, MCost

                OleDbCommand command = new OleDbCommand(sql, connection);
                OleDbDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string id = (string)reader["MobileId"];
                    string name = (string)reader["Name"];
                    string producer = (string)reader["Producer"];
                    int productYear = (int)reader["Production year"];
                    float cost = (float)reader["Cost"];

                    list.Add(new Mobile() { MId = id, MName = name, MProducer = producer, MProductYear = productYear, MCost = cost });
                }

                connection.Close();
            }
            return list;
        }





OleDbDataReader reader = command.ExecuteReader();当我调试

我已多次创建新数据库



Error in OleDbDataReader reader = command.ExecuteReader(); when i debug
And i had created new database many times

推荐答案

添加一个答案将其从未答复列表中移出。

Adding one answer to move it from unanswered list.
引用:

谢谢大家!

@Andrew Cherednik,我忘了在我的MobileList中将表重命名为Mobile .accdb!

Thanks everyone!
@Andrew Cherednik, i forget rename table to Mobile in my MobileList.accdb!


对不起,我的MobileList.accdb不包含表Mobile
Sorry, my MobileList.accdb not contain a table "Mobile"


这篇关于Microsoft Office Access数据库引擎找不到输入表或查询“Mobile”。确保它存在并且其名称拼写正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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