Sorting and Filtering Dynamically
If a query returns a large set of records, the results will be more useful if the user can define the order in which the rows are returned and which rows should be filtered out.
Adding a Sort Order to a Dynamic Query
To sort a dynamic query, just append the ORDER BY clause followed by a list of columns in the order indicated by the user. If the user wants to get the information in descending order, also append the DESC keyword.
In the following code, the order selections are stored in a special collection called SortInfo, a custom class designed to store all the information needed for each order selection.
Public Class SortInfo Public SchemaName As String Public TableName As String Public ColumnName As String ...