TClientDataSet 提交时提示 Field value Required 但是未提示具体哪个字段。

这个错误特别麻烦,要使用 midas 控件时,虽然很方便。但是出错了根本找不到原因,特别是这个异常。
下面的补丁,可以帮助找到错误原因。

注:我们自己在使用的时候,采用了控件继承,因此可以把这个功能变成控件基本功能,但是继承相关代码特别多,就不在这里贴了。

 procedure postAndCheckValue(ds: TDataSet);
var
I: Integer;
curField: TField;
strField: TStringField;
begin
try
ds.Post;
except
on E: EDBClient do begin
if E.Message = 'Field value required.' then begin
for I := to ds.Fields.Count - do begin
curField := ds.Fields[I];
if curField.Required and ds.Fields[I].IsNull then
raise EDBClient.Create('必要的数据项“' + ds.Fields[I].DisplayLabel + '”为空值!', E.ErrorCode); if curField.Required and (curField is TStringField) then begin
strField := curField as TStringField;
if strField.FixedChar and (strField.AsString = '') then
raise EDBClient.Create('必要的数据项“' + ds.Fields[I].DisplayLabel + '”为空值!', E.ErrorCode);
end;
end;
end;
raise;
end;
end;
end;

调用时,如果出错。就用这个进行提交即可:

myDataSet.append;

postAndCheckValue(myDataSet);

TClientDataSet 提交时提示 Field value Required 但是未提示具体哪个字段。的更多相关文章

  1. SpringBoot 启动的时候提示 Field *** in *** required a bean named 'entityManagerFactory' that could not be found.

    错误截图 后面发现原来和入口类代码有关. //@SpringBootApplication(scanBasePackages = {"org.jzc.odata.cboard",& ...

  2. Git提交时提示‘The file will have its original line endings in your working directory’

    Git提交时提示'The file will have its original line endings in your working directory' Git出现错误 git add -A ...

  3. easyui form提交时验证必填,打开时不显示必填提示

    给textbox添加required:true属性后,打开页面时整个表单都是红的,需要将其设置为提交时再验证. 解决方法:通过textbox的novalidate属性来控制是否开启验证 <inp ...

  4. svn提交时提示 Aborting commit: remains in conflict 解决办法,更改svn服务地址

    TortoiseSVN客户端如何更改新的URL 问题: 我们的服务器换了新的URL地址,这时候我们本地的SVN访问帐号和地址就要重新定义了. 解决步骤: 1:重新定义SVN的URL,右键(Tortoi ...

  5. svn提交时提示 Aborting commit: remains in conflict 解决办法

    出现在rename一个目录时,再提交时一直报错 Aborting commit: remains in conflict 使用右键菜单 svn - resolve 即可解决.用cleanup之类的都没 ...

  6. SVN hooks强制提交时填写日志

    #!/bin/bash REPOS="$1" TXN="$2" #svnlook路径 SVNLOOK=/usr/bin/svnlook #通过svnlook获取 ...

  7. SVN、Git设置提交时忽略的文件

    个人正在使用的:global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.pyc *.pyo [Tt]humbs.db [Bb]in [ ...

  8. SVN更新或提交时出现冲突该如何解决

    解决版本冲突的命令.在冲突解决之后,需要使用svnresolved来告诉subversion冲突解决,这样才能提交更新.冲突发生时,subversion会在WorkCopy中保存所有的目标文件版本(上 ...

  9. jQuery判断 form表单提交时一些文本框的判断

    一: form表单提交时如果表单里有input标签为空那么不提交form表单. <head> <script type="text/javascript"> ...

随机推荐

  1. mongose + express 写REST API

    一.准备工具 先确保电脑已经安装好nodejs 1.mongoose:安装非常简单: npm install mongoose --save   [mongoose封装了mongodb的方法,调用mo ...

  2. Java -- Web前端面试题及答案(需更深入了解)

    Web前端方面 1.CSS引入的方式有哪些? 1)外联:<link>标签 2)内联:<style>标签 3)元素内嵌:元素的style属性 2.CSS选择符有哪些? 标签选择符 ...

  3. HDFS hflush hsync和close的区别

    HDFS的hflush,hsync和close有啥区别,分别做了什么 hflush: 语义是保证flush的数据被新的reader读到,但是不保证数据被datanode持久化. hsync: 与hfl ...

  4. MariaDB实现主从配置及读写分离(一)

    一.主从复制方案 1.  在两台CentOS7虚拟机上分别部署MariaDB, 主数据库服务器IP为192.168.17.235, 从服务器IP为192.168.17.238. 从服务器通过调取主服务 ...

  5. PHP中unset,array_splice删除数组中元素的区别

    php中删除数组元素是非常的简单的,但有时删除数组需要对索引进行一些排序要求我们会使用到相关的函数,这里我们来介绍使用unset,array_splice删除数组中的元素区别吧 如果要在某个数组中删除 ...

  6. tikv性能参数调优

    tiKV 最底层使用的是 RocksDB(tidb3.0版本中将使用tian存储引擎) 做为持久化存储,所以 TiKV 的很多性能相关的参数都是与 RocksDB 相关的.TiKV 使用了两个 Roc ...

  7. 4星|《门口的野蛮人2》:美国宝万之争专业户KKR公司的疯狂借债收购史

    门口的野蛮人2:KKR与资本暴利的崛起(珍藏版) 英文版是1992年出的.主要内容是1977-1998年之间KKR在美国的杠杆收购简史.从KKR创立开始,讲到1990年KKR差点倒闭.国内A股市场上前 ...

  8. Python代码小片段

    1.前面变量值的改变不影响后面变量的调用 index=1 index,a=2,index+1 print(a,index) #2 2 2.类的继承(子类实例如何调用父类同名方法) class a: d ...

  9. sql !=与null

    在写SQL 条件语句是经常用到 不等于‘<>’的筛选条件,此时要注意此条件会将字段为null的数据也当做满足不等于的条件而将数据筛选掉. 例:表A A1  B1 1 0 2 1 3 NUL ...

  10. css3自定义滚动条背景透明

    .editor{ overflow:hidden; height:640px; padding:0 45px; border: 0 none; outline: none; } .editor::-w ...