How to 'foreach' a column in a DataTable using C#? - Stack Overflow

PHOTO EMBED

Fri Jul 22 2022 04:52:17 GMT+0000 (UTC)

Saved by @axzam #cs

DataTable dtTable;

MySQLProcessor.DTTable(mysqlCommand, out dtTable);

// On all tables' rows
foreach (DataRow dtRow in dtTable.Rows)
{
    // On all tables' columns
    foreach(DataColumn dc in dtTable.Columns)
    {
      var field1 = dtRow[dc].ToString();
    }
}
content_copyCOPY

https://stackoverflow.com/questions/7939146/how-to-foreach-a-column-in-a-datatable-using-c