如何使用TADODataset创建和使用聚合字段?

时间:2021-11-04 22:30:11

I can create a new aggregate field (TAggregateField ) with TADODataset in design mode, With expression "Sum(MyPrice)" (MyPrice is a field in this data set).

我可以在设计模式下使用TADODataset创建一个新的聚合字段(TAggregateField),表达式为“Sum(MyPrice)”(MyPrice是此数据集中的一个字段)。

but this field does not display anything in the binded DBText control (it is simply empty).

但是此字段在绑定的DBText控件中不显示任何内容(它只是空的)。

Can TAggregateField even be used with TADODataset? (all examples I have seen were related to TClientDataSet)

TAggregateField甚至可以与TADODataset一起使用吗? (我见过的所有例子都与TClientDataSet有关)

1 个解决方案

#1


3  

None of the ADO dataset based components shipped with Delphi supports aggregate fields. They would have to implement aggregate support methods (such as e.g. GetAggregateValue) of the TDataSet ancestor.

Delphi附带的基于ADO数据集的组件都不支持聚合字段。他们必须实现TDataSet祖先的聚合支持方法(例如GetAggregateValue)。

To your question, yes, you can use TAggregateField with shipped ADO components (there's nothing what would restrict you) but it's useless because such field will always return NULL value due to missing GetAggregateValue method implementation in ADO components.

对于您的问题,是的,您可以将TAggregateField与已发布的ADO组件一起使用(没有什么会限制您),但它没用,因为由于缺少ADO组件中的GetAggregateValue方法实现,此类字段将始终返回NULL值。

#1


3  

None of the ADO dataset based components shipped with Delphi supports aggregate fields. They would have to implement aggregate support methods (such as e.g. GetAggregateValue) of the TDataSet ancestor.

Delphi附带的基于ADO数据集的组件都不支持聚合字段。他们必须实现TDataSet祖先的聚合支持方法(例如GetAggregateValue)。

To your question, yes, you can use TAggregateField with shipped ADO components (there's nothing what would restrict you) but it's useless because such field will always return NULL value due to missing GetAggregateValue method implementation in ADO components.

对于您的问题,是的,您可以将TAggregateField与已发布的ADO组件一起使用(没有什么会限制您),但它没用,因为由于缺少ADO组件中的GetAggregateValue方法实现,此类字段将始终返回NULL值。