Search code examples
c#foreachdatarow

how to select all rows from a DataTable


I can't seem to figure out how to just return all rows when using Select on a DataTable.

My code so far:

foreach (DataRow r in data.Select("Sort != null", "Sort"))
{ //process }

I get the following error:

Cannot interpret token '!'

The Sort column is of type Guid and is used to return the rows in a random order.


Solution

  • Try this instead...

    foreach (DataRow r in data.Select("Sort IS NOT NULL", "Sort"))
    { //process }