使用TQuery.state in [dsEdit, dsInsert],我可以检查DataSet是否处于某些给定状态。是否有办法检查它是否处于给定的状态?
我已经尝试过TQuery.state <> [dsEdit, dsInsert],导致了Incompatible types错误和not Query.State in [dsEdit, dsInsert],但是之后我得到了错误Operator not applicable to this operand type。
在单击此按钮时,我是ApplyingUpdates,当有人delete记录来自DataSet的记录时,我也需要这样做,但是没有状态检查这种情况。
发布于 2017-09-28 08:00:35
当然了。写这个的方法是
if not (Query1.State in [dsEdit, dsInsert]) then ....获得Operator not applicable to this operand type错误的原因是Delphi中操作符的优先级。Not具有比Query1.State in [...]更高的优先级,所以当编译器看到not Query1时,知道Query1不是布尔值,就会引发Operator not applicable ...错误。
https://stackoverflow.com/questions/46463899
复制相似问题