I have a question about DataTable. I retrieve a DataTable from the database, and one of these columns contains either a 1 or a 0. Now I want to retrieve only the rows with a 1 value of 1 in that column.
The name of the column is ACTIVATE.
Here is my DataTable:
DataTable table = new DataTable(TABLE);
//How can I filter here so ACTIVATE == 1?
adapter.Fill(table);
connection.Open();
selectcommand.ExecuteReader();
return table;
Via SQL (preferred)
Via
Linq-To-Datatable(in memory):If you’re still on .NET 2, you can use
DataTable.Select:Apart from that, you don’t need
selectcommand.ExecuteReader()to fill the table.