Rs. getrows usage

Source: Internet
Author: User

Ado also provides a more efficient way to obtain information. The getrows method returns the number of changes in a two-dimensional column. Each row corresponds to a memory in the recordset, and each column corresponds to the memory position in the recordset. The compile method of this method is as follows:

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

Rows is the number of records to be retrieved. If you want to retrieve all records of A recordset, use-1 or omit this number. Start indicates the first primary node to be retrieved. It can also be a constant in the lower column: 0-adbookmarkcurrent, 1-adbookmarkfirst), or 2-adbookmarklast (last record ).

Fields is an optional parameter name used to limit the amount of data to be retrieved. (You can also specify a single-digit index, a single-digit index, or a single-digit index column ). When the rows is set to less than the recordset log records, the records not retrieved in the first row become the current row. If the number of rows is omitted or set to-1-adgetrowsrest or greater than the number of unknown rows, the getrows method Retrieves all the records and places the recordset In the EOF primary keys, instead, it will generate no response.

When processing data changes in the target data column, we should remember that the data storage method is somewhat opposite: in the dimension column, the first parameter defines the information bit of the recordset, and the second parameter defines the information column of the recordset. The following is an example of three memory locations in the recordset:

Dim values as variant, fldindex as integer, recindex as integer
Values = Rs. getrows (, array ("lastname", "firstname", "birthdate "))
For recindex = 0 to ubound (values, 2)
For fldindex = 0 to ubound (values)
Print values (fldindex, recindex ),
Next
Print
Next

The getrows method is usually faster than the record loop of a primary key. However, when using this method, you must make sure that the recordset does not contain too many records. Otherwise, it is easy to fill in a large variable column for all the audios. Based on the same reason, be careful not to include any blob (Binary Large Object) or clob (character large object) bitwise; if so, applications will be cracked, especially for large recordset. Finally, remember that the variable column returned by this method is based on 0; the variable number returned by this method is ubound (values, 2) + 1, the number of round return bits is ubound (value, 1) + 1.

The getstring method is similar to the getrows method, but the getstring method returns multiple records that exist in the form of a single string. The getstring signature method is as follows:

Getstring ([format], [numrows], [coldelimiter], [rowdelimiter], [nullexpr])

Format is the result format. Getstring may also support more formats, but currently the only supported format is 2-adclipstring, so there is no choice in the response. Numrows is the number of columns to be obtained. (Use-1 or omit this parameter to retrieve all the remaining records .) Coldelimiter is a line delimiter (Delimiter is set as a Tab character ). Rowdelimiter is the delimiter used to record the delimiter ). Nullexpr is a string used to represent the null delimiter (the Delimiter is set to an empty string ). The file states that only when format = adclipstring, the last three parameters can be used, but this warning does not mean much because (as mentioned earlier) this format is currently only supported. In the following example, the getstring method is used to extract data into a text segment separated by segments:

Dim I as long
Open "datafile.txt" for output as #1
For I = 0 to Rs. Fields. Count _ 1 'export field names.
If I> 0 then print #1 ,";";
Print #1, Rs. Fields (I). Name;
Next
Print #1 ,""
Rs. movefirst 'export data.
Print #1, Rs. getstring (, ";", vbcrlf); 'don' t add an extra CR-LF here.
Close #1

The getstring method does not allow only the child sets with the given bits to be written, or the sequence of the given bits to be modified. If you need these functions, you should use the getrows method and create the final string by yourself.

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.