当前位置: 首页 > news >正文

c#,vb.net使用OleDb写入Excel异常:字段太小而不能接受所要添加的数据的数量

碰到问题:excel文件,有一列只是100来个字符,结果无法修改数据,除非给他清空内容

我的解决方法是:把数据导入到ACCESS处理,再设置加锁,多个IIS用户只能排队一个一个通过,因为ACCESS无法多线程写入,大部分大型数据库也没法多线程同时写入吧?

以下是网上找到的一些ADO相关的原因:


"the field is too small to accept the amount of data "_odbc字段太小而不能接受所要添加的数据的数量-CSDN博客
https://blog.csdn.net/u010032207/article/details/52171487

从Excel电子表格导入时,您会看到以下错误消息:
“[Microsoft][ODBC Excel驱动程序]字段太小,无法接受您尝试添加的数据量。请尝试插入或粘贴较少的数据”。

这是Excel ODBC驱动程序的问题,通常可以通过重新排序电子表格中的记录来解决。

从根本上说,Excel不是一个数据库,电子表格中的列没有与数据库相同的数据类型。Excel ODBC驱动程序必须对给定列的数据类型做出假设。驾驶员通过提前读取8条记录并查看找到的数据来实现这一点。然后,它根据读取的数据类型做出决定。当后续记录证明关于数据类型的假设是错误的时,就会出现问题。考虑两种情况…。

Excel电子表格中的列中有一列包含字符串数据。前8条记录包含短字符串(比如20-30个字符)。Excel ODBC驱动程序读取此数据,并假定短字符串数据类型适用于此列。如果后续记录包含更长的字符串(比如300个字符)。数据类型可能不合适,无法存储较长的字符串,上述错误是由Excel ODBC驱动程序引发的。将带有长字符串的记录移动到数据集的开头,将允许Excel ODBC为该列选择更合适的数据类型,该列将应用于电子表格中的所有记录。
电子表格中的列具有前8条记录的数字字符串,例如“123”、“456”等。Excel确定此列包含数字数据。后续记录包含一个非数字数据的字符串,例如“Hello World”。
Excel ODBC驱动程序所做的假设将被证明是不正确的,ODBC驱动程序将引发上述错误消息。这个问题可以通过重新考虑记录的顺序来解决。如果包含“hello world”的记录位于前8条记录中。Excel ODBC驱动程序将确定此列包含字符串数据,并希望选择适用于所有数据记录的字符串数据类型。
在所有情况下,该技术都是安排记录的顺序,以便允许Excel ODBC驱动程序正确选择数据类型。

============
While importing from an Excel spread sheet you see the following error message:
"[Microsoft][ODBC Excel Driver] The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data".

This is problem with the Excel ODBC driver which can often be worked around by reordering the records in the spreadsheet.

Fundamentally, Excel is NOT a database and the columns in a spreadsheet do not have a data type associated with them in the same way that that a database does. The Excel ODBC driver has to make an assumption about the data type for a given column. The driver does this by reading ahead 8 records and looking at the data found. It then makes a decision about the data type based upon what it has read. Problems occur when the assumption about data type is proven wrong by subsequent records. Consider two scenarios….
==============

A column in an Excel spreadsheet has a column in it which contains string data. The first 8 records contain short strings, (let's say 20-30 characters). The Excel ODBC driver reads this data and assumes that a short string data type will be appropriate for this column. If a subsequent record contains a longer string, (let's say 300 characters). The data type may prove inappropriate and unable to store the longer string and the error above is raised by the Excel ODBC driver. Moving the record with the long string to the beginning of the dataset will allow the Excel ODBC to select a more appropriate data type for the column which will apply to all records in the spreadsheet.
A column in a spreadsheet has numeric strings for the first 8 records, For example "123", "456" etc. Excel decides that this column has numeric data. A subsequent record contains a string which is not numeric data, for example "Hello World".

 The assumption made by the Excel ODBC driver will prove incorrect and the above error message will be raised by the ODBC driver. The problem can be worked around by reconsidering the order of the records. If the record containing "hello world" is placed within the first 8 records. The Excel ODBC driver will determine that this column contains string data and hopefully a string data type will be selected which will be appropriate for all data records.

In all cases the technique is to arrange the order of the records such that the Excel ODBC driver is allowed to make the correct selection of data type.

相关文章:

  • 【无标题】C++单例模式详解
  • CentOS 7 下 Redis 从 5.0 升级至 7.4.3 全流程实践
  • 人工智能模型方面有哪些优化措施,可以提升模型的准确率
  • 嵌入式开发--STM32G431无法正常运行程序,BOOT0与CAN冲突
  • 第五十五节:综合项目实践-实时人脸美化滤镜
  • (独家)SAP WIP生产订单结算报错:没有估算额;不可能结算
  • lto.o
  • 78. Subsets和90. Subsets II
  • Claude 4对比Claude 3.7全面评测:2025最新AI模型实测对比
  • Femap许可证与网络安全策略
  • APP广告变现,开发者如何判断对接的广告SDK安全合规?
  • 注意力机制模块代码
  • windows中Redis、MySQL 和 Elasticsearch启动并正确监听指定端口
  • 实时数仓flick+clickhouse启动命令
  • 聊一聊 .NET Dump 中的 Linux信号机制
  • Spark SQL进阶:解锁大数据处理的新姿势
  • 编程规范Summary
  • C++ STL stack容器使用详解
  • 2025 年江西研究生数学建模竞赛题A题电动汽车充电桩共享优化与电网安全协同模型完整思路 模型代码 结果 成品分享
  • 浙大版《Python 程序设计》题目集6-3,6-4,6-5,6-6列表或元组的数字元素求和及其变式(递归解法)
  • 网站开发软件有哪些免费/百度点击软件名风
  • 做网站能赚钱吗表情包/短链接购买
  • 网站建设中的图片/今日头条官网首页
  • 品牌网站建设哪个好/重庆专业seo
  • 中国建设监理协会网站会员专区/推广策略可以分为哪三种
  • 广州珠吉网站建设/海外seo是什么