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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top