How to iterate through a DataTable

后端 未结 4 1439
死守一世寂寞
死守一世寂寞 2020-11-29 19:51

I need to iterate through a DataTable. I have an column there named ImagePath.

When I am using DataReader I do it this way:

4条回答
  •  猫巷女王i
    2020-11-29 20:25

    foreach (DataRow row in myDataTable.Rows)
    {
       Console.WriteLine(row["ImagePath"]);
    }
    

    I am writing this from memory.
    Hope this gives you enough hint to understand the object model.

    DataTable -> DataRowCollection -> DataRow (which one can use & look for column contents for that row, either using columnName or ordinal).

    -> = contains.

提交回复
热议问题