srk1982
asked on
Problem in getting the data from excel to a dataset
hello experts,
I am using the below code to export excel 2007 to dataset.
but i am getting the below 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.
where it is going wrong ??? please help
urgent.. thanks.
I am using the below code to export excel 2007 to dataset.
but i am getting the below 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.
where it is going wrong ??? please help
urgent.. thanks.
string Filetype = FileUpload1.PostedFile.ContentType.ToString();
if (Filetype == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
{
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strFilename + ";Extended Properties=\"Excel 8.0;\"";
OleDbDataAdapter myOleDbDataAdapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);
DataSet ExcelDataSet = new DataSet();
myOleDbDataAdapter.Fill(ExcelDataSet, "[Sheet1$]");
myOleDbDataAdapter = null;
return ExcelDataSet;
}
ASKER
hi SameerJagdale,
i tried that...
I am getting this error now....
{System.Data.OleDb.OleDbEx ception: External table is not in the expected format.
at System.Data.OleDb.OleDbCon nectionInt ernal..cto r(OleDbCon nectionStr ing constr, OleDbConnection connection)
at System.Data.OleDb.OleDbCon nectionFac tory.Creat eConnectio n(DbConnec tionOption s options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.D bConnectio nFactory.C reateNonPo oledConnec tion(DbCon nection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.D bConnectio nFactory.G etConnecti on(DbConne ction owningConnection)
at System.Data.ProviderBase.D bConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbCon nection.Op en()
at System.Data.Common.DbDataA dapter.Qui etOpen(IDb Connection connection, ConnectionState& originalState)
at System.Data.Common.DbDataA dapter.Fil lInternal( DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataA dapter.Fil l(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataA dapter.Fil l(DataSet dataSet, String srcTable)
at MenuManager_OperationalInf o.getExcel Data(Strin g strFilename) in d:\Applications\IOIF\MenuM anager\Ope rationalIn fo.aspx.cs :line 33}
i tried that...
I am getting this error now....
{System.Data.OleDb.OleDbEx
at System.Data.OleDb.OleDbCon
at System.Data.OleDb.OleDbCon
at System.Data.ProviderBase.D
at System.Data.ProviderBase.D
at System.Data.ProviderBase.D
at System.Data.OleDb.OleDbCon
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at System.Data.Common.DbDataA
at MenuManager_OperationalInf
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Provider=Microsoft.Jet.OLE