inidac update时 出现Update failed. Found 2 records的解决办法

Problem with StrictUpdate property of class "TDADataSetOptions" in DBAccess file

If we see the help for StrictUpdate property of class "TDADataSetOptions" in DBAccess file, it says:

"StrictUpdate TCustomDADataSet raises exception when number of the updated or deleted records does not equal to 1. Setting this option also causes an exception if RefreshRecord procedure returns more than one record. The exception does not occur when you use non-SQL block."

In our application, there is an instance, where on clicking the delete button, all the records displayed in a grid are deleted. In that scenario, the FUpdateQuery.RowsAffected count is greater than 1 and in the following condition of 'PerformSQL' function of the 'DBAcess.pas' file :
------------------------------------------------------------------------------------
" if FOptions.StrictUpdate and
//(Command.SQLType in [SQL_INSERT,SQL_UPDATE,SQL_DELETE]) and /// for ODAC
((FRowsAffected = 0) or (FRowsAffected > 1))
then
DatabaseError(Format(SUpdateFailed, [FRowsAffected])); "
-----------------------------------------------------------------------------------
is giving an error Message.

This is happening because the parameter "StrictUpdate " is set to true in the constructor of class "TDADataSetOptions"
If we change the value to 'false' in the construtor, the error is not raised and application is running fine.

Will setting "StrictUpdate " to false in the constructor can have severe implications on other db operations ?

Please instruct Us regarding the same and any other possible solutions other than this.

Waiting for your clarification on the same,


It is safe to set StrictUpdate to False in constructor.
It won't affect any other database operations except the ones listed in SDAC Help in the description of the StrictUpdate property.


转自:http://forums.devart.com/viewtopic.php?t=9537

http://forums.devart.com/viewtopic.php?f=6&t=29879&p=102475&hilit=Update+failed+Found#p102475
http://forums.devart.com/viewtopic.php?f=6&t=9606


如果把StrictUpdate设置为true;更新的数据如果大于一行,或者没有数据更新的话,就会报以下的类似的信息: Update failed. Found 6 records。但是数据库的数据此时已经更新了。





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值