Sorting and Filtering a DataSet

If you know how to write SQL, you know that you can sort and filter data with ORDER BY and WHERE clauses. However, this approach requires that you requery the database each time the view changes. Such requerying is an expensive and impractical operation, especially when you have thousands of simultaneous users and the data has already been queried.

With ADO.NET you have better alternatives. You can read data into a DataSet and change the view and order of the data without requerying the database. You can change the order and rows with the DataView.RowFilter and Sort properties or with the DataTable.Select method. The subsections that follow contain examples of each of these.

Filtering and Sorting a DataView

The ...

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.