2012-08-01 66 views
0

我希望能夠遍歷DataRow列表,如下所示。類型不匹配,無法將System.Data.DataRowCollection分配給System.Data.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陣列 。」

如何遍歷數據表中的行列表?

由於提前,

回答

1

使用System.Data.DataRowCollection.CopyTo(),它是專門做正是這一點。

public override void CopyTo(
Array ar, 
int index 
) 

參數是要複製到的數組和複製應從其開始的從零開始的索引。

相關問題