Microsoft Remote Data ServiceMicrosoft Remote Data Service*
*Contents  *Index  *Topic Contents

Sorting and Filtering

You can sort and filter a Recordset object using the RDS.DataControl sort and filter properties and methods. Sorting orders the records in the Recordset in a specific order (for example, by first name or invoice number), and filtering restricts the result set of records that meet some criteria (for example, employee records whose title is manager).

Tip When you already know how you want to sort and filter your data, it's faster to sort and filter the Recordset by using an SQL string that uses an ORDER BY and WHERE clause.

Sorting a Recordset

You can set the SortColumn and SortDirection properties of the RDS.DataControl object, and then call the Reset method to sort the Recordset on the client-side cache and refresh the results that are displayed in the data-bound controls. The Reset method will execute the criteria and replace the current Recordset with a read-only Recordset.

Filtering a Recordset

You can use the FilterValue, FilterCriterion, and FilterColumn properties of the RDS.DataControl object, and then call the Reset method to filter a Recordset on the client-side cache and refresh the results that are displayed in the data-bound controls. Again, the Reset method will execute the criteria and replace the current Recordset with a read-only Recordset.

Navigating through Recordset Objects

Navigation through Recordset objects is based on the concept of a current record. You can imagine that the current record as the particular record that is highlighted by an invisible cursor as you move through the Recordset.

You can use the Move methods with the RDS.DataControl object to navigate through the data records displayed in the data-bound controls on a Web page. For example, suppose you display a Recordset in a grid by binding to an RDS.DataControl object. You can then include First, Last, Next, and Previous buttons that users can click to move to the first, last, next, or last record in the displayed Recordset. You do this by calling the MoveFirst, MoveLast, MoveNext, and MovePrevious methods of the RDS.DataControl object in the OnClick procedures for the First, Last, Next, and Previous buttons, respectively:

' Move to the first record in the bound recordset.
Sub First_OnClick
	ADC1.Recordset.MoveFirst
End Sub

' Move to the next record from the current position 
' in the bound recordset.
Sub Next_OnClick
	ADC1.Recordset.MoveNext
End Sub

' Move to the previous record from the current position
' in the bound recordset.
Sub Previous_OnClick
	ADC1.Recordset.MovePrevious
End Sub

' Move to the last record in the bound recordset.
Sub Last_OnClick
	ADC1.Recordset.MoveLast
End Sub

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.