OleDbDataAdapter data mapping error using Jet

I use OleDbDataAdapter(Microsoft.ACE.OLEDB.12.0, to be precise) to retrieve data from an Excel workbook. For one table I use a typed dataset, but for another table I cannot do this because the number of columns is unknown (Excel template can generate additional columns).

The problem was that if someone enters too many numeric values ​​in a column, "JET" seems to consider it a numeric column, and text values ​​are no longer loaded. I know that you can change the template and set a specific data type for this column, but the template is already widespread, so I would rather allow it during import.

Now I tried to first count the number of columns used and prepare a new DataTable with a specific collection of columns and set their DataType property to a value typeof(string). Unfortunately, JET does not seem to be looking at this and is still choosing its own path. I guess that even if I could use a strongly typed dataset here, that would not help and ...

Does anyone know how to tell JET how to import data, so I don’t have to worry about providing a new version of the template?

Please * PLEASE * : do not come with Excel Automation Solution ...

+3
source share
1 answer

TypeGuessRows = 0 / ImportMixedTypes = Text. .

+3

All Articles