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());
}*/
}
Suthish NairPosted Mar 31, 2011, 1:26 PM
Suthish NairPosted Mar 30, 2011, 9:59 AM
VulpesPosted Mar 30, 2011, 4:12 AM
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from[sheet1$]", MyConnection);
Raju KatarePosted Mar 30, 2011, 3:27 AM