【问题标题】:Type mismatch, cannot assign System.Data.DataRowCollection to array of System.Data.DataRow类型不匹配,无法将 System.Data.DataRowCollection 分配给 System.Data.DataRow 数组
【发布时间】:2012-08-01 15:39:57
【问题描述】:

我希望能够使用 For each 循环遍历 DataRow 列表,如下所示。

  ArrayOfRows: Array of DataRow;

  ArrayOfRows := dbtable.Rows;

  for each therow in ArrayofRows do
  begin
    ITagList.Add(therow['TAGNAME'].ToString);
  end;

但我一直跑到错误,

"类型不匹配,无法将 System.Data.DataRowCollection 分配给数组 的 System.Data.DataRow。”

如何遍历数据表中的行列表?

提前致谢,

【问题讨论】:

    标签: sqlite datatable datarow delphi-prism oxygene


    【解决方案1】:

    使用System.Data.DataRowCollection.CopyTo(),它就是专门为此而设计的。

    public override void CopyTo(
    Array ar,
    int index
    )
    

    参数是要复制到的数组,以及从零开始复制的索引。

    【讨论】:

      猜你喜欢
      • 2017-10-05
      • 2021-04-17
      • 1970-01-01
      • 1970-01-01
      • 2015-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-18
      相关资源
      最近更新 更多