当前位置: 首页 > 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.

http://www.xdnf.cn/news/668233.html

相关文章:

  • etcd:高可用,分布式的key-value存储系统
  • 鸿蒙OSUniApp 实现登录状态管理与持久化#三方框架 #Uniapp
  • 如何通过ES实现SQL风格的查询?
  • linux快速入门-VMware安装linux,配置静态ip,使用服务器连接工具连接,快照和克隆以及修改相关配置信息
  • 【机器学习基础】机器学习入门核心算法:逻辑回归(Decision Tree)
  • 第一章 LVS 负载均衡群集核心概念与体系架构
  • 计算机网络实验课(三)——直接使用数据构造以太网帧,打包并发送|使用SharpPcap库函数构造以太网帧,并发送出去
  • 哈希算法:原理、应用、安全演进与推荐
  • 学习路之PHP--easyswoole入门及文件热加载
  • 织梦dedecms arclist最新发布日期显示红色
  • Android 15 控制亮屏灭屏接口实现
  • WPF【11_2】WPF实战-重构与美化(Entity Framework)-示例
  • 数据仓库基础知识总结
  • Python-ArcGIS蒸散发组分解析与GPP估算技术
  • 数据中台(大数据平台)之数据仓库建设
  • LLM+RAG:文本分块处理策略
  • Apache DolphinScheduler存储系统详解| AI生成技术文档系列
  • Vue3进阶教程:1.初次了解vue
  • Mobaxterm解锁Docker
  • Docker Desktop for Windows 系统设置说明文档
  • DBCP连接池的使用方法和源码分析
  • PCB布局/走线
  • 2025年上半年第2批信息系统项目管理师论文真题解析与范文
  • 深入理解Java中的BigDecimal:高精度计算的核心工具
  • 第二批考更有利?软考高项两个批次考试难度对比分析!
  • 银河麒麟V10×R²AIN SUITE:用AI重构安全,以国产化生态定义智能未来
  • Ansible 配置Playbook文件格式、关键字和语法详解
  • 每日Prompt:古花卷
  • 探究Azure devops 流水线缓存
  • 详解MYSQL索引失效问题排查