0

The Microsoft Office Access database engine could not find the object 'Sheet1$$A7:B'. Make sure the object exists and that you spell its name and the path name correctly.

using (OleDbConnection excel_con = new OleDbConnection(conString))
        {
            excel_con.Open();
            string sheet1 = excel_con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null).Rows[0]["TABLE_NAME"].ToString();
            DataTable dtExcelData = new DataTable();

            //[OPTIONAL]: It is recommended as otherwise the data will be considered as String by default.
            dtExcelData.Columns.AddRange(new DataColumn[3] { new DataColumn("PersonId", typeof(int)),
            new DataColumn("Name", typeof(int)),
            new DataColumn("Salary",typeof(decimal)) });

            using (OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM [" + sheet1 + "$" + "A7:B]", excel_con))
            {
                oda.Fill(dtExcelData);
            }
            excel_con.Close();
HAPPYsukh
  • 15
  • 1
  • 1
  • 7
  • 2
    Possible duplicate of [The Microsoft Office Access database engine could not find an object](http://stackoverflow.com/questions/20417626/the-microsoft-office-access-database-engine-could-not-find-an-object) – Blue May 22 '17 at 04:59
  • Check your question by yourself then you'll see that your object must be Sheet1$A7:B. Try changing your query string to `"SELECT * FROM [" + sheet1 + "A7:B]"` – kashi_rock May 22 '17 at 05:06
  • It worked. Thank you – HAPPYsukh May 22 '17 at 05:14

0 Answers0