← Back to The Recordset Object
Lesson 4

Advanced Recordset Methods

The Recordset Object · Created 2026-06-01 13:34:28

Search, sort, filter, extract, clone, save, and work with batch operations.

Find
rs.Find 'title = ''Request'''
If Not rs.EOF Then Response.Write 'Found: ' & rs('title')
rs.Find 'id > 5'
Supports: =, <>, !=, >=, <=, >, <

GetRows
Dim rows : rows = rs.GetRows() ' returns 2D array [col][row]
Dim rowCount : rowCount = UBound(rows, 2) + 1
Dim nRows : nRows = rs.GetRows(10) ' get 10 rows only

Sort
rs.Sort = 'title ASC, id DESC'
Client-side sorting of all fetched rows (no SQL ORDER BY)
Setting Sort resets cursor to first row

Filter
rs.Filter = 'id > 3 AND title LIKE ''%ASP%'''
Client-side filtering from cached rows
Setting Filter resets cursor to first row

Clone
Set rs2 = rs.Clone() ' independent copy with same data
rs2.MoveFirst : rs.MoveLast ' each navigates separately

Save to CSV
rs.Save Server.MapPath('data/export.csv')

Requery
rs.Requery ' re-execute original SQL on same connection

Supports
If rs.Supports(adUpdate) Then ... ' always returns True

NextRecordset
Set rs = conn.Execute('SELECT * FROM a; SELECT * FROM b')
Set rs2 = rs.NextRecordset() ' get second result

Batch Operations
rs.LockType = 4 ' adLockBatchOptimistic
rs.Open 'SELECT * FROM courses', conn
' ... modify fields on multiple rows ... '
rs.UpdateBatch ' apply all changes
rs.CancelBatch ' discard pending batch changes

Live Demo →