FireDAC 出现Variable length column[*] overflow. Value length - [80], column maximum length

FireDAC的 TFDQuery组件访问SQLlite数据库,使用insert into语句插入一条数据长度为80的字符串,但是用 select * from 查询的时候却出现异常:[FireDac][DatS]-32. Variable length column[Namee] overflow. Value length - [80], column maximum length - [40].,出现错误的原因我很清楚,数据库中字段长度是40,无法读取80个字节的数据,但是为什么插入的不提示错误,查询的时候才出现异常,这要是万一插入超长的数据,以后就没办法读取了,而且也不知道是那条数据超长了,因为只要表中有一条超长的数据,select * from 语句就会返回这个异常,根本无法读取整个表中的内容。

经过查询资料,多次测试,找到了下面两种解决方法

方法1:

修改TFDConnection下面的两个属性

  • FormatOptions.OwnMapRules 设置为 True
  • FormatOptions.MapRules 添加两个子项,第一个子项的两个属性 SourceDataType = dtWideString,TargetDataType = dtWideMemo;第二个子项的两个属性dtAnsiString, TargetDataType = dtWideMemo

上述方法是将字符串类型字段映射为Memo类型的字段,Memo类型的字段是不判断长度的,就不会出现这种异常了,使用TFDQuery.FieldByname('name').AsString可以获取完整的80个字符。

这种方法存在一个问题,在使用DBGrid显示这些数据的时候,会显示为TMemo也就是DBGrid不能直接将Memo类型显示出来。

方法2:

修改TFDConnection下面的1个属性

  • FormatOptions.StrsTrim2Len 设置为True
这个方法是将超长的数据截断,也就是只取得前面40个字符。

FireDAC 出现Variable length column[*] overflow. Value length - [80], column maximum length的更多相关文章

  1. Maximum length of a table name in MySQL

    http://dev.mysql.com/doc/refman/5.7/en/identifiers.html The following table describes the maximum le ...

  2. oracle 导入报错:field in data file exceeds maximum length

    今天用sqlldr导入数据时候报错: " Record 1: Rejected - Error on table ks_test, column khname.Field in data f ...

  3. sqlldr Field in data file exceeds maximum length "

    使用sqlldr导数时出现如下错误: " Record 1: Rejected - Error on table PC_PLANNAME, column PLANNAME.Field in ...

  4. [LeetCode] Maximum Length of Repeated Subarray 最长的重复子数组

    Given two integer arrays A and B, return the maximum length of an subarray that appears in both arra ...

  5. [Swift]LeetCode718. 最长重复子数组 | Maximum Length of Repeated Subarray

    Given two integer arrays A and B, return the maximum length of an subarray that appears in both arra ...

  6. [LeetCode]Maximum Length of Repeated Subarray

    Maximum Length of Repeated Subarray: Given two integer arrays A and B, return the maximum length of ...

  7. LeetCode Maximum Length of Pair Chain

    原题链接在这里:https://leetcode.com/problems/maximum-length-of-pair-chain/description/ 题目: You are given n  ...

  8. 718. Maximum Length of Repeated Subarray

    Given two integer arrays A and B, return the maximum length of an subarray that appears in both arra ...

  9. LN : leetcode 646 Maximum Length of Pair Chain

    lc 646 Maximum Length of Pair Chain 646 Maximum Length of Pair Chain You are given n pairs of number ...

随机推荐

  1. JDK1.8 HashMap$TreeNode.balanceInsertion 红黑树平衡插入

    红黑树介绍 1.节点是红色或黑色. 2.根节点是黑色. 3.每个叶子节点都是黑色的空节点(NIL节点). 4 每个红色节点的两个子节点都是黑色.(从每个叶子到根的所有路径上不能有两个连续的红色节点) ...

  2. HDU:2255-奔小康赚大钱(KM算法模板)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2255 奔小康赚大钱 Time Limit: 1000/1000 MS (Java/Others) Mem ...

  3. Centos7 install Openstack Juno (RDO) (转载)

    原文地址:http://www.hdume.com/centos-7-0%E5%AE%89%E8%A3%85openstack/ 1.安装系统,Centos7镜像采用CentOS-7.0-1406-x ...

  4. 2019 study list

    分析工具: (1)SQL   select from   where   group by having   order by   limit   运算符(算数运算符+-*/.比较运算符>< ...

  5. while else语句

    #else 用于检测循环中间是否有被打断count = 0while count <=5: print('loop',count) count +=1else: print('程序正常执行完毕, ...

  6. luogu2756 飞行员配对方案问题

    匈牙利 #include <iostream> #include <cstring> #include <cstdio> using namespace std; ...

  7. GridView的RowCommand事件中获取每行控件的值

    //获取当前行                GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).Parent.Parent; //获取 ...

  8. 豆邮windows客户端(第三方)开发详解

    “豆邮”,是社区网站“豆瓣”的一个类似私信的功能模块.在豆瓣官网,“豆邮”曾一度被改为“私信”,但在遭到众多豆瓣用户的强烈反对之后又改了回来.然而,在豆瓣的移动客户端上,仍称呼为“私信”. 豆邮的设定 ...

  9. Leetcode3--->无重复字符的最长子串长度

    题目:给定一个字符串string,找出string中无重复字符的最长子串. 举例: Given "abcabcbb", the answer is "abc", ...

  10. python中用exit退出程序

    在python中运行一段代码,如果在某处已经完成整次任务,可以用exit退出整个运行.并且还可以在exit()的括号里加入自己退出程序打印说明.不过注意在py3中要加单引号或双引号哦!