数据保存时,出现‘record not found or changed by another user’错误信息的解决办法
2011-07-02 15:13
746 查看
'record not found or changed by another user',这个错误是我在做项目时,遇到的问题,找了一些参考才解决。如下:
所用的控件有:TDataSetProvider,TADOQuery,TClientDataSet
1.当 DataSetProvider.UpdateMode=upWhereAll 时,update时 where 是指定全部字段,比如,你有a、b、c 3个字段,修改了c字段,在app server中修改的命令是update ... set c=新c where a=旧a and b=旧b and c=旧c
如果 旧的a、b、c之一 已经被其他人改掉了,那where就找不到合适的记录来修改了。所以报告“记录被其他人修改”,这个问题和“锁定”是无关的。
2.当 DataSetProvider.UpdateMode=upWhereKeyOnly 时,update时 where 是指定key字段,比如,
你有a、b、c 3个字段,修改了c字段,a是key field在app server中修改的命令是update ... set c=新c where a=旧a (只比较a字段)你的程序应该设计为客户修改不到主键字段的值,这样你的客户只能修改到其他字段的值,其他字段不会出现在where中,就不会出现你说的问题了。
(用第2种方法解决,注意如果你的表原来没有主键的,需要双击dataset,添加你的所有field,在有唯一值的field的 ProviderFlasgs 属性里面 InKey 设置为 true (该field必须是有唯一值的,能相当于主键的,也就是能唯一确定该行记录的),TADOQuery,TClientDataSet控件里的唯一值的field字都要设置InKey为true)
所用的控件有:TDataSetProvider,TADOQuery,TClientDataSet
1.当 DataSetProvider.UpdateMode=upWhereAll 时,update时 where 是指定全部字段,比如,你有a、b、c 3个字段,修改了c字段,在app server中修改的命令是update ... set c=新c where a=旧a and b=旧b and c=旧c
如果 旧的a、b、c之一 已经被其他人改掉了,那where就找不到合适的记录来修改了。所以报告“记录被其他人修改”,这个问题和“锁定”是无关的。
2.当 DataSetProvider.UpdateMode=upWhereKeyOnly 时,update时 where 是指定key字段,比如,
你有a、b、c 3个字段,修改了c字段,a是key field在app server中修改的命令是update ... set c=新c where a=旧a (只比较a字段)你的程序应该设计为客户修改不到主键字段的值,这样你的客户只能修改到其他字段的值,其他字段不会出现在where中,就不会出现你说的问题了。
(用第2种方法解决,注意如果你的表原来没有主键的,需要双击dataset,添加你的所有field,在有唯一值的field的 ProviderFlasgs 属性里面 InKey 设置为 true (该field必须是有唯一值的,能相当于主键的,也就是能唯一确定该行记录的),TADOQuery,TClientDataSet控件里的唯一值的field字都要设置InKey为true)
相关文章推荐
- 数据保存时,出现‘record not found or changed by another user’错误信息的解决办法
- 数据保存时,出现‘record not found or changed by another user’错误信息的解决办法
- record not found or changed by another user
- [DataSet Error] Record not found or changed by another user
- 关于Record not found or changed by another user的问题
- 问题-"Record not found or changed by another user"
- clientdataset“Record not found or changed by another user”问题
- 数据保存时,出现‘record not found or changed by another user’错误信息的解决办法
- Oracle修改数据时提示“record is locked by another user”的解决办法
- DataGrid保存数据时出现错误解决办法.
- Oracle 数据库 Record is locked by another user 问题解决办法
- Oracle 数据库 Record is locked by another user 问题解决办法
- Oracle 数据库 Record is locked by another user 问题解决办法
- Oracle 数据库 Record is locked by another user 问题解决办法
- cloudera-scm-server启动出现Error creating bean with name 'entityManagerFactoryBean'与HHH010003: JDBC Driver class not found: com.mysql.jdbc.Driver错误解决办法(图文详解)
- oracle 表记录被locked的解决办法,record is locked by another user
- 出现错误 Element type "LinearLayout" must be followed by either attribute specification,">"or"/>"的解决办法
- LINQ:row not found or changed.错误提示可能的解决方法之一
- git 出现The current branch is not configured for pull No value for key branch.master.merge found in configuration错误的解决办法
- 插入数据是的时候出现错误解决办法:MassAssignmentException in Model.php line 407: username