Data truncated after 255 bytes while using Microsoft.Ace.Oledb.12.0 provider

前端 未结 5 810
抹茶落季
抹茶落季 2021-01-21 04:43

I am reading an excel sheet using the ACE provider and certain cells contain data greater than 255 bytes. I tried changing the TypeGuessRows in the registry settings as well as

5条回答
  •  长情又很酷
    2021-01-21 05:22

    The problem is that the ACE driver is inferring a TEXT data type for the column you're populating the data set from. Text columns are limited to 255 characters. You need to force it to use the MEMO data type.

    Your best bet for that is to garantee that the majority of the first eight rows in that column exceed 255 characters in length.

    Source

    This behavior is determined by the the predictive nature of the Excel driver/provider. Since it doesn't know what the data types are, it has to make a guess based upon the data in the first several rows. If the contents of a field exceeds 255 characters, and it's in the first several rows, then the data type will be Memo, otherwise it will probably be Text (which will result in the truncation).

提交回复
热议问题