Make Rs. getrows clearer.

Source: Internet
Author: User

RS used. the getrow brother knows Rs. getrow can be used to obtain small-capacity data more efficiently (it is not suitable for large-capacity data, especially when it involves large objects, it is easy to get rid of it, and I just went through it once). puterjam is a good example.

However, Rs. getrow returns a two-dimensional array, and we often don't know which segment to which. This is very troublesome.ProgramConvenient debugging:

Dim DS
Set objrs = objconn. Execute ("select * from [blog_upload] Where ([ul_quote] Like '%" & CSTR (ID) & "% ')")
DS = objrs. getrows
Objrs. Close ()
Set objrs = nothing

'Create a table
Response. Write "written by SIPO (www.dc9.cn) <Table align =" "center" "border =" "1" ">"
Response. Write vbcrlf
Response. Write "<tr> <TD> </TD>"
For J = 0 to ubound (DS, 1)
Response. Write "<TD> DS (" & J & ", x) </TD>"
Next
Response. Write "</tr>"
'Each row
For I = 0 to ubound (DS, 2)
Response. Write "<tr> <TD> DS (x," & I & ") </TD>" & vbcrlf
'Each Column
For J = 0 to ubound (DS, 1)
Response. Write "<TD>"
If isnull (DS (J, I) then
Response. Write "null"
Else
Response. Write DS (J, I)
End if
Response. Write "<br>"
Response. Write "<B> DS (" & J & "," & I & ") </B>"
Response. Write "</TD>"
Next

Response. Write "</tr>" & vbcrlf
Next

Response. End

--------------------------------------------------------------------------------

To cainiao:
Tips for getrows:

Ado also provides a more efficient way to obtain data. The getrows method returns a two-dimensional array variable. Each row corresponds to a record in the recordset and each column corresponds to the field in the record. The syntax of this method is as follows:

Vararray = Rs. getrows ([rows], [start], [fields])

Rows indicates the number of records to be read. If you want to obtain all records of the recordset, use-1 or omit this parameter. Start indicates the first bookmark to be read. It can also be one of the following enumerated constants: 0-adbookmarkcurrent (current record), 1-adbookmarkfirst (first record), or 2-adbookmarklast (last record ).

Fields is an array of optional field names used to limit the amount of data to be read. (You can also specify a single field name, a single field index, or a field Index Array ). When the rows value is set to less than the number of records in the recordset, the First unread record becomes the current record. If the rows parameter is omitted or set to-1-adgetrowsrest or greater than the number of unread records, the getrows method reads all records and puts the recordset In the EOF state without generating any errors.

When processing the data of the destination variable array, remember that the data storage method is a bit opposite: the first dimension of the array defines the recordset field (Data row ), the second dimension defines the recordset data column.

The getrows method is usually faster than reading a record at a time, but when using this method, you must ensure that the recordset does not contain too many records; otherwise, it is easy to fill up all the memory with a very large array of variables. For the same reason, be careful not to include any blob (Binary Large Object) or clob (character large object) fields. If this is done, the application will be cracked, especially for large recordset. Finally, remember that the array of variables returned by this method is based on 0; the number of records returned is ubound (values, 2) + 1, and the number of returned fields is ubound (value, 1) + 1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.