I'm using VS 2010 with C# for a Windows Form application.
I need to load my data from the Excel sheet onto a DataSet. I created the DataSet using the DataSet designer and I manually added the tables and columns (FirstTable, Column1, Column2)
. Since I access the columns a lot, the code would be a lot cleaner to have a typed dataset instead of using an untyped one.
When I used the OleDBDataAdapter and populated the DataTable using Fill on FirstTable
, Column1
and Column2
were empty and there were two additional columns that were from the Excel sheet (ExcelCol1, ExcelCol2)
. So unless, I gave the same excel columns names to FirstTable
(instead of Column1
and Column2
if I called it ExcelCol1
and ExcelCol2
), it would not populate the DataColumns that I created via the designer.
Is there any way to tell the DataSet to ignore the columns coming from Excel and just populate the already defined DataColumns?
IF that is not possible can I somehow connect the Excel sheet via a DataConnection to create the layout of the DataTables? The only thing I'm not sure about is that the excel file is user defined, so the user browses to the excel file to populate the DataSets. BUT the columns for all these excel files will always be the same. Hence I want to preset the layout using a Typed DataSet.