Sorting the result in a DataTable’s select command can be done as below.
DataTable table = dataSet.Tables[0]; // Get a datatable from the dataset.
DataRow[] row = table.Select("id = 500", "name desc, age asc"); // Get from table, where id = 500 order by name desc and age desc.
The first argument to the select is the filter condition, the second argument is the sort option.
Trying to use,
DataTable table = dataSet.Tables[0]; // Get a datatable from the dataset.
DataRow[] row = table.Select("id = 500 order by name desc, age asc"); // Get from table, where id = 500 order by name desc and age desc.
will result in a error “Missing operand before order”.
Leave a reply to Rajeshwaran S P Cancel reply