Everyone should know that Recordset has a GetRows attribute, but not many of them are actually used, and I have only used it recently! sweat……
In fact, this property is very simple, it is to output the data set into an array. But it is quite practical. Here I will give an example to illustrate how to use GetRows. You can think of more usage by learning from it!
For example, a classification table T_Cate, the structure and data are as follows:
ID|Title|Intro
-----------------------------------------
1|News|This is news
2|Tutorial|Here is the tutorial
3|Download|Here is download
OK, the table is established and the data is also available. Now we will use GetRows!
The code copy is as follows:
DimRs_Cate
DimArr_Cate
SetRs_Cate=Conn.ExeCute("SELECTID,Title,IntroFROMT_CateORDERBYIDASC")
Arr_Cate=Rs_Cate.GetRows
SetRs_Cate=Nothing
OK, the table data has been exported to the array! Next we will iterate through this array
The code copy is as follows:
DimArr_CateNumS,Arr_CateNumI
Arr_CateNumS=Ubound(Arr_Cate,2)'Get subscript of data in the array
ForArr_CateNumI=0ToArr_CateNumS
Response.Write("ID:"&Arr_Cate(0,Arr_CateNumI)&"|Title: "&Arr_Cate(1,Arr_CateNumI)&"|Introduction: "&Arr_Cate(2,Arr_CateNumI)&"<br>")
Next
Haha, OK, the output data is:
ID: 1 | Title: News | Introduction: Here is the news
ID: 2 | Title: Tutorial | Introduction: Here is the tutorial
ID: 3 | Title: Download | Introduction: Here is the download
Okay, so much to write! The literary talent is not good. If you don’t understand anything, just use it more. Haha