Click here to Skip to main content
15,918,275 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
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))

                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 });

            return list;

Error in OleDbDataReader reader = command.ExecuteReader(); when i debug
And i had created new database many times
Maciej Los 2-Apr-14 14:48pm    
Try to around table name with [] brackets and add ; at the end of sql statement.
Krunal Rohit 2-Apr-14 14:50pm    
He's right. Try that out.

chaau 2-Apr-14 18:27pm    
Does your MobileList.accdb contain a table called Mobile?
KasGuest 2-Apr-14 23:00pm    
Thanks everyone!
@Andrew Cherednik, i forget rename table to Mobile in my MobileList.accdb!

Adding one answer to move it from unanswered list.
Thanks everyone!
@Andrew Cherednik, i forget rename table to Mobile in my MobileList.accdb!
Share this answer
Sorry, my MobileList.accdb not contain a table "Mobile"
Share this answer
BillWoodruff 9-Dec-14 21:21pm    
Please post replies to questions, or comments as comments, not solutions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900