How to force ADO.Net to use only the System.String DataType in the readers TableSchema

后端 未结 4 641
情书的邮戳
情书的邮戳 2021-01-17 15:08

I am using an OleDbConnection to query an Excel 2007 Spreadsheet. I want force the OleDbDataReader to use only string as the column datatype.

The system is looking a

4条回答
  •  生来不讨喜
    2021-01-17 15:16

    Check out the final answer on this page.


    Just noticed the page you refer to says the same thing ...


    Update:

    The problem seems to be with the JET engine itself and not ADO. Once JET decides on the type, it sticks to it. Anything done after that has no effect; like casting the values to string in the SQL (e.g. Cstr([Column])) just results in an empty string being returned.

    At this point (if there are no other answers) I'd opt for other methods: modifying the spreadsheet; modifying registry (not ideal since you will be messing with the settings for every other app the uses JET); Excel automation or a third party component that does not use JET.

    If Automation option is to slow then maybe just use it to save the spreadsheet in a different format which is easier to handle.

提交回复
热议问题