| [ASP] detailed usage of GetRows! We should all know that Recordset has a GetRows attribute, but there are not many actually used ones. I also recently used it! Khan ...... In fact, this attribute is very simple, that is, to output the dataset to an array. However, it is not practical. Here I will give an example to illustrate how to use GetRows. You can think of more things! For example, the structure and data of T_Cate are as follows: ID | Title | Intro ----------------------------------------- 1 | news 2 | tutorial | here is the tutorial 3 | download Okay, the table has been created and the data has been created. We will use GetRows next!
| CODE: |
|
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 |
|
The table data has been exported to the array! Next we will traverse this arrayWell, the output data is: ID: 1 | title: News | Introduction: News ID: 2 | title: tutorial | Description: This is a tutorial. ID: 3 | title: download | Description: Download
| CODE: |
|
Dim Arr_CateNumS, Arr_CateNumI Arr_CateNumS = Ubound (Arr_Cate, 2) 'to obtain 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) & "| Description:" & Arr_Cate (2, Arr_CateNumI) & "<br> ") Next |
|
Well, let's write so much! It's not a good literary talent. If you don't understand anything, you can use it more. For more information about GetRows, you can read related articles. I will not talk about it here! |
GetRows Method
Restore multiple records of the Recordset object to the array.
Syntax
Array=Recordset. GetRows ( Rows,Start,Fields)
Return Value
Returns a two-dimensional array.
Parameters
Rows Optional,Long IntegerExpression to specify the number of records to be retrieved. The default value isAdGetRowsRest(-1 ).
Start Optional,StringOrLong IntegerInGetRowsBookmarks of records at the beginning of the operation. You can also use the followingBookmarkEnumValue.
| Constant |
Description |
| AdBookmarkCurrent |
Starting from the current record. |
| AdBookmarkFirst |
Start with the first record. |
| AdBookmarkLast |
Start with the end record. |
FieldsOptional,ShapingRepresents a single field name, a sequential position, an array of field names, or a sequential position number. ADO returns only the data in these fields.
Description
UseGetRowsMethod to extract records fromRecordsetCopy to a two-dimensional array. The first subscript identifies the field, and the second identifies the record number. WhenGetRowsThe group variable is automatically adjusted to the correct size when the method returns data.
If you do not specifyRowsParameter value,GetRowsMethod will be automatically retrievedRecordsetAll records in the object. If the requested record is more than the available recordGetRowsOnly the number of available records is returned.
IfRecordsetThe object supports bookmarks. You can specifyGetRowsMethod to retrieve data from which record.
To limitGetRowsTo call the returned field, you can FieldsInput a single field name/number or field name/number array.
Before callingGetRowsThe next unread record becomes the current record, or if there are no more records, the EOF attribute is setTrue.