We should all know that the Recordset has a GetRows attribute, but the real use is not much, I also recently used! Sweat......
In fact, this property is very simple, that is, the dataset output to an array. But the practicality is not small, here I give an example to explain GetRows use method, everybody extrapolate can think of more usage!
For example, a categorized table t_cate, structure and data are as follows:
ID | Title | Intro
-----------------------------------------
1 | News | This is the news.
2 | Tutorials | Here is the tutorial
3 | Download | Here is the download
OK, the table is established, the data also has, below we will use to getrows slightly!
Dim rs_cate
Dim arr_cate
Set rs_cate=conn.execute ("Select Id,title,intro from T_cate order by ID ASC")
Arr_cate=rs_cate.getrows
Set rs_cate=nothing
Okay, table data has been exported to the array! Here we will iterate over this array
Dim Arr_catenums,arr_catenumi
Arr_catenums=ubound (arr_cate,2) ' Gets the subscript of the data in the array
For Arr_catenumi=0 to Arr_catenums
Response.Write ("ID:" &arr_cate (0,arr_catenumi) & "| title:" &arr_cate (1,arr_catenumi) & "| Introduction:" &ARR_ Cate (2,arr_catenumi) & "<br>")
Next
Oh, well, the output of the data is:
id:1 | Title: News | Introduction: Here is the news
Id:2 | Title: Tutorials | Introduction: Here is the tutorial
Id:3 | Title: Download | Introduction: Here is the download
All right, so much for writing! Literary talent is not good, if we have what do not understand, more use can be, hehe
Attached: source 51windows.net
GetRows method
Restores multiple records of a Recordset object to an array.
Grammar
Array = Recordset. GetRows (Rows, Start, Fields)
return value
Returns a two-dimensional array.
Parameters
Rows optional, long-integer expression that specifies the number of records to retrieve. The default value is Adgetrowsrest (-1).
Start optional, string, or long integer to calculate the bookmark for the record at the beginning of the GetRows operation. You can also use the following BookmarkEnum values.
Constants Description
Adbookmarkcurrent starts at the current record.
Adbookmarkfirst begins with the first record.
Adbookmarklast begins with the tail record.
Fields Optional, Variant type that represents a single field name, ordinal position, field array group, or ordinal position number. ADO returns only the data in these fields.
Description
Use the GetRows method to copy records from a recordset into a two-dimensional array. The first subscript identifies the field, and the second identifies the record number. When the GetRows method returns data, the array variable is automatically resized to the correct size.
If you do not specify the value of the Rows parameter, the GetRows method automatically retrieves all the records in the Recordset object. If the requested record is more than the available record, GetRows only returns the number of available records.
If the Recordset object supports bookmarks, you can specify which record the GetRows method will start retrieving data by passing the value of the Bookmark property of the record.
To restrict the fields returned by the GetRows call, you can transfer a single field name/number or an array of field names/numbers in the Fields parameter.
After calling GetRows, the next unread record becomes the current record, or if there are no more records, the EOF property is set to True.