w3pop.com :: 网络学院 :: ADO :: ADO GetRows 方法
The GetRows method copies multiple records from a Recordset object into a two-dimensional array.
GetRows的作用是:将一个记录集对象中的多个记录复制到一个二维数组中。
vararray=objRecordset.GetRows(rows,start,fields) |
| Parameter参数 | Description描述 |
|---|---|
| rows | Optional. A GetRowsOptionEnum value that specifies the number of records to retrieve. Default is adGetRowsRest. 可选参数。指定一个GetRowsOptionEnum值,用于指定需要提取记录的数量。默认值为adGetRowsRest Note: If you omit this argument it will retrieve all records in the Recordset |
| start |
Optional. What record to start on, a record number or a BookmarkEnum value |
| fields | Optional. If you want to specify only the fields that the GetRows call will return, it is possible to pass a single field name/number or an array of field names/numbers in this argument 可选参数。如果你只指定字段,那么将返回GetRows请求;你可以将一个字段值/字段号或是一个“字段值/字段号”数组传到该自变量中 |
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
'The first number indicates how many records to copy
'The second number indicates what recordnumber to start on
p=rs.GetRows(2,0)
rs.close
conn.close
'This example returns the value of the first
'column in the first two records
response.write(p(0,0))
response.write("<br>")
response.write(p(0,1))
'This example returns the value of the first
'three columns in the first record
response.write(p(0,0))
response.write("<br>")
response.write(p(1,0))
response.write("<br>")
response.write(p(2,0))
%>
|
| Constant常量 | Value值 | Description描述 |
|---|---|---|
| adGetRowsRest | -1 | Retrieves the rest of the records in the Recordset object 提取记录集对象中的剩余记录 |
| Constant常量 | Value值 | Description描述 |
|---|---|---|
| adBookmarkCurrent | 0 | Starts at the current record 指定从当前记录开始 |
| adBookmarkFirst | 1 | Starts at the first record 指定从第一条记录开始 |
| adBookmarkLast | 2 | Starts at the last record 指定从最后一条记录开始 |
评论 (0)
All