网友提交的测试例子,我测了是有内存泄漏,附件发不上了,下面是代码段 procedure TForm1.Button1Click(Sender: TObject); var FAgg: TAggregate; begin if not ClientDataSet1.Active then ClientDataSet1.LoadFromFile('RY.XML'); ClientDataSet1.AggregatesActive := False; with ClientDataSet1 do begin FAgg := Aggregates.Find('BasicWage'); if FAgg = nil then begin FAgg := Aggregates.Add; FAgg.AggregateName := 'BasicWage'; FAgg.Expression := 'SUM(BasicWage)'; FAgg.Active := False; end; end;
ClientDataSet1.AggregatesActive := True; FAgg.Active := True; ClientDataSet1.IndexFieldNames := 'Rymc'; if not VarIsNull(FAgg.Value) and (FAgg.Value <> null) then ShowMessage(FloatToStr(FAgg.Value));