i use this code for reading the data from excelsheet. but the error" The Microsoft Jet database engine could not find the object ''Sheet1$''. Make sure the object exists and that you spell its name and the path name correctly " will displayed. plz help.
{
System.Data.OleDb.OleDbConnection MyConnection ;
System.Data.DataSet DtSet ;
System.Data.OleDb.OleDbDataAdapter MyCommand ;
MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='d:\\csharp.net-informations.xls';Extended Properties=Excel 8.0;");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from[Sheet1$]", MyConnection);
MyCommand.TableMappings.Add("Table", "TestTable");
DtSet = new System.Data.DataSet();
MyCommand.Fill(DtSet);
dataGridView1.DataSource = DtSet.Tables[0];
// MessageBox.Show("connected");
MyConnection.Close();
/* catch (Exception ex)
{
MessageBox.Show (ex.ToString());
}*/
}

Raju KatareRank #1,971 · 742 reputationPosted Mar 29, 2011, 11:27 PM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 30, 2011, 12:12 AM EDT
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from[sheet1$]", MyConnection);
Suthish NairRank #92 · 22.8K reputationPosted Mar 30, 2011, 5:59 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Mar 31, 2011, 9:26 AM EDT