Data Table problem

  • Thread starter Thread starter Jerry S
  • Start date Start date
J

Jerry S

Hi

I've got a DataSet with one table in it.

I want to iterate through all the rows in a particular column in the
table, each time doing something with the value that is returned.

I can't find out how to do it! Surely it must be easy.

Any help greatly appreciated!

Many thanks.

Best regards,

Jerry
 
Jerry,

If there is one table in the data set, then it can be accessed through
the Tables property. Passing an indexer of 0 will return the table. Once
you have that, you can iterate through the Rows property, getting the value
from the column like so:

// Assume the table is in a variable named pobjTable.
foreach (DataRow pobjRow in pobjTable.Rows)
{
// Do something with the row. The default indexer for the row
// returns the column value for that row.
// e.g. pobjRow["stringColumn"].
}

Hope this helps.
 
Back
Top