简体   繁体   中英

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.

Try this instead...

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

You could also try:

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

How about

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM