关于DBGrideh出现Dataset not in edit or insert mode
来源:互联网 发布:联通网络解锁助手 编辑:程序博客网 时间:2024/05/01 12:11
前两天一直在对DBGrideh 进行操作,我是做一个checkbox 的选择框,对没勾选的记录点击进行添加数据,对有勾选的记录点击进行是否删除数据。我是在选择框的数据改变是事件onupdatedata的事件中对数进行修改,但有时候可以修改,有时候就会出现adoquery1: dataset not in edit or insert mode 的错误,我百思不得其解。
在网上找了好久,有人说是把DBGrideh 关连的adoquery 的locktype的值设为ltBatchOptimistic,但这只能在正确的操作时才不会出错。但可想而知道,你做的软件是给别人用的,不是给自己用的,你必须考虑到别人有可能出现在错误操作,从而对这个错误操作进行处理。
经过我好长时间的测试,我发现在DBGrideh 的事件或是在DBGrideh 的colouns 的事件中对DBGrideh 的值和对DBGrideh 关连的adoquery的值进行修改就会产生adoquery1: dataset not in edit or insert mode 的错误,我之前有的没有出错的原因是因为我是在事件里新创建一个窗体,然后在这个窗体的某一个事件或某一个控件的事件里对DBGrideh 的值和对DBGrideh 关连的adoquery的值进行修改。也就是说不用要在DBGrideh 的事件或是DBGrideh 的colouns 的事件中对其数据进行修改就不会出错了。
但是我在想,你不可能每次都要跳出一个窗体,再对这个窗体进行操作之后才会对DBGrideh 的数据进行修改。只要在DBGrideh 的事件或是在DBGrideh 的colouns 的事件中要修改时,跳到另一个窗体或控件,然后让这个窗体或控件自动执行代码,而没有显示什么东西出来不就可以了!想通了之后我第一个想到的就是Timer控件。只要把Timer的Enabled默认值设为false,把Timer的Interval的值设得小一点(可以在10左右),把要修改数据的代码放在Timer的ontimer事件里,但是在这些代码前要先放上Timer1.Enabled:=false; 之后只要在需要执行修改数据的代码时把Timer1.Enable:=true;就可以了。
我想到的目前就是用新窗体各Timer来解决,希望名位看者能想出更好的解决办法,到时也给我留下言,让我也能多学点东西!
- 关于DBGrideh出现Dataset not in edit or insert mode
- 关于DBGrideh出现Dataset not in edit or insert mode
- 修改数据结果出现dataset not in edit or insert mode
- VSTO Check Cell is In Edit Mode or Not
- Share point designer 里的 "Edit in advanced mode" 不出现
- How to detect "edit mode" in excel
- introduce insert/overwrite mode to 'CEdit' derived edit control
- Vue.js Devtools inspection is not available because it's in production mode or explicitly disabled
- 出现SQL insert, update or delete failed (row not found)错误,原因总结:
- 插入模块出现Error: could not insert module testsecond.ko: Device or resource busy
- 解决VS 2008出现EMM intrinsics not supported in the pure mode
- spring boot 发送邮件带附件出现Not in multipart mode - create an appropriate MimeMessageHelper错误
- 用Unitils测试DAO时出现Write operations are not allowed in read-only mode异常
- 关于oracle登录出现ORACLE initialization or shutdown in progress
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- GSO,TSO and UFO
- orcle 物化视图
- 闭包
- MFC DLL 与 Delphi DLL的互相调用要注意的问题
- Apache Commons Logging 是如何决定使用哪个日志实现类的
- 关于DBGrideh出现Dataset not in edit or insert mode
- WWW-Authenticate 注销方法
- SLF4J教程
- 好的习惯
- VS找不到MFC90d.dll错误
- log4j详解
- 互动网计算机频道图书7日销售排行(05.27-06.02)
- 用Spring提供的test jar包帮助测试用到HTTP request的类
- oUpFileStream.Write Request.BinaryRead (Request.TotalBytes)上传提示错误 0104