关于DBGrideh出现Dataset not in edit or insert mode
2010-04-29 10:40
369 查看
前两天一直在对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 关连的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
- 修改数据结果出现dataset not in edit or insert mode
- delphi dataset not in edit or insert mode
- VSTO Check Cell is In Edit Mode or Not
- 关于Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- Share point designer 里的 "Edit in advanced mode" 不出现
- 关于ssh里面的Write operations are not allowed in read-only mode (FlushMode.NEVER)
- [转]关于NSAutoreleasePool' is unavailable: not available in automatic reference counting mode的解决方法
- 关于java的Graphics出现“Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.”
- 关于Jedis连接Linux上的redis出现 DENIED Redis is running in protected mode问题的解决方案
- 解决VS 2008出现EMM intrinsics not supported in the pure mode
- 关于Android studio安装出现“ 'tools.jar' seems to be not in Android Studio classpath..."的问题
- Target host or target server ***** is not in operation mode
- 关于clover2运行时出现的"annotations are not supported in -source 1.3"错误的解决
- 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
- 关于打开Eclipse时出现eclipse failed to create the java virtual machine与locking is not possible in the directory问题的解决
- ssh整合的时候出现错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- 使用JSTL tag时出现错误:According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- 关于NSAutoreleasePool' is unavailable: not available in automatic reference counting mode