The below exception was caught while importing excel data into application.Two worksheets are available in the excel file,first worksheet data gets imported properly into a Dataset,but second worksheet data doesn't,exception was caught at
dataAdapter.Fill(dsData); line in below Lines of Code.
strSQL = "SELECT * FROM [" + sheetName + "$]";
dbCommand = new OleDbCommand(strSQL, excelConnection);
dataAdapter = new OleDbDataAdapter(dbCommand);
dataAdapter.Fill(dsData);
Exception Description:
System.Data.OleDb.OleDbException was caught
Message="Too many fields defined."
Source="Microsoft JET Database Engine"
ErrorCode=-2147467259
StackTrace:
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at ImportData.ReadExcelFile(String filePath)
InnerException:
Please do the needfull,any help is appreciated and thankful.