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. img,a,锚链接,超链接

    1.图片标签:img,单标签 图片属性: src(source): 图片的来源(路径),可以放置本地图片,也可以放网上的图片的url地址 title: 当鼠标停留在图片上的时候,显示提示的文字 alt ...

  2. ActiveReports 报表控件V12新特性 -- 无需ETL处理,即可实现跨数据源分析数据

    ActiveReports是一款专注于 .NET 平台的报表控件,全面满足 HTML5 / WinForms / ASP.NET / ASP.NET MVC / WPF 等平台下报表设计和开发工作需求 ...

  3. Maven的下载与安装(Windows版本)

    前言: 安装Maven 3,需要安装jdk1.7及以上版本 具体步骤如下: 1.进入官网:http://maven.apache.org/download.cgi,如下图红框部分 其中: apache ...

  4. Express使用Https服务器

    var fs = require('fs'); var http = require('http'); var https = require('https'); var privateKey = f ...

  5. 字符串匹配常见算法(BF,RK,KMP,BM,Sunday)

    今日了解了一下字符串匹配的各种方法. 并对sundaysearch算法实现并且单元. 字符串匹配算法,是在实际工程中经常遇到的问题,也是各大公司笔试面试的常考题目.此算法通常输入为原字符串(strin ...

  6. python 多进程、多线程

    1.多线程: 下面讲一个简单用法,这个模块比较简单,但是实际使用中会遇到很多坑 from multiprocessing import process def go(s): print "主 ...

  7. 学习vue.js的正确姿势(转载)

    最近饶有兴致的又把最新版 Vue.js 的源码学习了一下,觉得真心不错,个人觉得 Vue.js 的代码非常之优雅而且精辟,作者本身可能无 (bu) 意 (xie) 提及这些.那么,就让我来吧:) 程序 ...

  8. leetCode题解之Longest Palindrome

    1.题目描述 2.问题分析 直接用hash table 做就行. 3.代码 int longestPalindrome(string s) { ) ; map<char,int> m; f ...

  9. Oracle EBS GL总账凭证取值

    SELECT gh.je_header_id, gh.period_name, gh.default_effective_date, gh.je_source, gs.user_je_source_n ...

  10. Android external扩展工程

    Android的扩展工程包含在external文件夹中,这是一些经过修改后适应Android系统的开源工程,这些工程有些在主机上运行,有些在目标机上运行: 工程名称  工程描述  aes  高级加密标 ...