[英]How to get FireDAC record count when SetRange active
I'm slowly moving from ClientDataSet to FireDAC FDQuery components in my projects (Delphi 10 Seattle). 我正慢慢地从ClientDataSet转移到我的项目中的FireDAC FDQuery组件(Delphi 10 Seattle)。
One trick I often use with CDS is to check record count on a range. 我经常使用CDS的一个技巧是检查范围上的记录计数。
That is: 那是:
CDS.SetRange([Value1][Value2]);
k := CDS.RecordCount;
case k of
1 : DoSingleThing;
2 : DoDoubleThing;
else
BailOnWrongCount;
end;
Because I need the entire set of data available at the same time, I use FetchOptions.Mode := fmAll when first opening the query. 因为我需要同时提供整个数据集,所以在第一次打开查询时我使用FetchOptions.Mode:= fmAll。
Doing FDQuery.SetRange([Value1][Value2]);
做
FDQuery.SetRange([Value1][Value2]);
then calling FDQuery.RecordCount
always returns the record count of the entire dataset (as per fmAll) - not the current range. 然后调用
FDQuery.RecordCount
总是返回整个数据集的记录数(按照fmAll) - 而不是当前范围。
I'm having to loop through the range counting records manually. 我不得不手动遍历范围计数记录。
Is there a simpler way to get the number of records in the current range? 是否有更简单的方法来获取当前范围内的记录数?
将FetchOptions.RecordCountMode设置为cmVisible: http ://docwiki.embarcadero.com/Libraries/Seattle/en/FireDAC.Stan.Option.TFDFetchOptions.RecordCountMode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.