无法将计算字段添加到clientdataset

编程入门 行业动态 更新时间:2024-10-25 11:31:38
本文介绍了无法将计算字段添加到clientdataset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用下面的代码向在 fieldDefs.add 创建的现有数据集中添加一个计算字段,并在包括堆栈溢出在内的多个站点上找到了许多变体。

I am trying to add a calculation field to an existing data set created with fieldDefs.add using the code below with many variations I found on several sites including stack overflow.

但是 fieldDefs 行创建的 fieldDefs dataSet 行中的 FieldDefs.count 丢失。

But the fieldDefs created by the fieldDefs line or by the dataSet line are lost on update by FieldDefs.count.

Fields.counts 保留,但不会保存到XML文件中。

Fields.counts persist but are not saved to XML files.

没有引发异常。

有人知道这里发生了什么吗? 谢谢

Does anyone have any idea what is going on here? Thanks

MYclientDataSet.CreateDataSet; MYclientDataSet.open; MYclientDataSet.FieldDefs.Update; MYclientDataSet.Active := False; for i := 0 to MYclientDataSet.FieldDefs.Count - 1 do MYclientDataSet.FieldDefs[i].CreateField(MYclientDataSet); fld := TStringField.Create(MYclientDataSet); with fld do begin FieldName := 'PartSummary'; FieldKind := fkCalculated; Calculated := True; Name := cds.Name + FieldName; DataSet := MYclientDataSet; MYclientDataSet.FieldDefs.Add('PartSummary', ftString, 30, false); MYclientDataSet.FieldDefs.update; end; MYclientDataSet.active := true; MYclientDataSet.open; MYclientDataSet.edit;

推荐答案

根据Delphi教育链接中的Cary Jensen 定义Clientdataset的结构... 您无法使用FieldDefs创建计算,查找,汇总字段。您必须改用TFields。

According to Cary Jensen in the Delphi education link Defining a Clientdataset's Structure... you cannot create a calculated, lookup, aggregate field using FieldDefs. You must use TFields instead.

更多推荐

无法将计算字段添加到clientdataset

本文发布于:2023-10-31 07:50:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545485.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   clientdataset

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!