SteinTech
SteinTech

Reputation: 4068

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.

Upvotes: 2

Views: 5253

Answers (3)

Ilgeo
Ilgeo

Reputation: 9

How about

foreach (DataRow r in data.Select())
{ //process }

See https://learn.microsoft.com/en-us/dotnet/api/system.data.datatable.select?view=netframework-4.8

Upvotes: 1

G. LC
G. LC

Reputation: 822

You could also try:

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

Upvotes: 1

K Johnson
K Johnson

Reputation: 488

Try this instead...

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

Upvotes: 4

Related Questions