Learn the GetRows attribute of the recordset in detail by ASP

Source: Internet
Author: User

We should all know that the Recordset has a GetRows attribute, but the real use is not much, I also recently used!

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, all right. Table data has been exported to an array! Below we'll 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

Well, specifically write so much! Literary talent is not good, if we have what do not understand, more use on it, hehe



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.