Low cost ecommerce web development India flash website design
After opening a Recordset object, you can use the Move methods to move
forward and (depending on the cursor) backward through the data rows.
Recordset objects provide a RecordCount property, which tells you the
number of records in the Recordset object.
Think of a Recordset object as a table with an empty row at the top and
bottom, and a current-record pointer. The record pointer points to only one
record at a time. When you use one of the Move methods, you don't scroll the
record set - you move the record pointer. Recordset objects have EOF (endof-
file) and BOF (beginning-of-file) methods to let you know when the record
pointer has moved past the last record or prior to the first record. EOF and
BOF are Boolean properties.
While Not R.EOF
'Do something
R.MoveNext
Wend
It's important to check whether a Recordset object is at the BOF or EOF
position before requesting data, because Recordset objects raise an error if
you request data when the Recordset object is at either of these two positions.
Recordset Sorting and Searching Methods
You can search and sort data with Recordset methods, although it's much
more efficient to obtain only the data you need from the server and retrieve it
64
already sorted. To sort a record set, assign its Sort property the names of the
field(s) you want to sort by. For example, to sort the Recordset:
SELECT * FROM Students
by LastName, you would write:
R.Sort = "LastName"
To sort by more than one field, separate the field names with commas, as
follows:
R.Sort = "LastName, FirstName"
The default sort order is always ascending, so you don't need to write an
explicit direction (although you can). To sort in a specific order, append either
ASC or DESC to the end of the sort string.
R.Sort = "LastName, FirstName DESC”
You can also search for specific records in a record set. To perform the
search, use the Recordset.Find method. You specify the search conditions
with the equivalent of a SQL WHERE clause, without the word WHERE.
After performing a find, the Recordset object is positioned at the first record
found, or if no records are found, at the end of the Recordset (EOF).
You may include multiple conditions, just as in a WHERE clause. In addition
to the search criteria, the Find method accepts three other optional arguments:
§ SkipRecords
The number of records to skip before beginning the search. This argument
is particularly useful when you're searching in a loop. By setting
SkipRecords to 1, you can begin searching in the record following the
current record. When searching backward, set this value to a negative
number.
§ SearchDirection:
The direction to search, either adSearchForward or adSearchBackward.
§ Start:
The number or bookmark of the record where the search should begin. You
should specify either SkipRecords or Start, but not both.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73