locked
excel file not found problem RRS feed

  • Question

  •  if (textBox1.Text != null)
                {
                     string a=arr[0];
                    String con =@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='D:\Book1.xlsx';Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1'";
                    OleDbConnection conn = new OleDbConnection(con);

                    OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Book1]", conn);

                    da = new OleDbDataAdapter(cmd);
                    da.Fill(ds);
                    dataGridView1.DataSource = ds.Tables[0];

    }

       problem is -- The Microsoft Office Access database engine could not find the object 'Book1'.  Make sure the object exists and that you spell its name and the path name correctly.            
    Tuesday, August 6, 2013 12:40 PM

Answers

  • Hi vibhu mishra

              In Oledb Command you have given [Book1] which represents sheet name. Make sure the excel contains that sheet.

    Thanks

    Sowmiya

    • Marked as answer by vibhu mishra Tuesday, August 6, 2013 7:33 PM
    Tuesday, August 6, 2013 12:48 PM

All replies

  • Hi vibhu mishra

              In Oledb Command you have given [Book1] which represents sheet name. Make sure the excel contains that sheet.

    Thanks

    Sowmiya

    • Marked as answer by vibhu mishra Tuesday, August 6, 2013 7:33 PM
    Tuesday, August 6, 2013 12:48 PM
  • Thanks a lot ,its working

    Tuesday, August 6, 2013 7:32 PM