Bytes Expert Newtork: Connect with experts in IT / Business | Expert Topics



Search


Go Back   Programmers Resource > Code Section > ASP Articles
User Name
Password


 
 
Thread Tools Search this Thread Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 06-13-2003, 03:17 PM
admin admin is offline
Administrator
 
Join Date: May 2003
Posts: 116
Using GetRows

The GetRows method is used to retrieve a recordset into a 2 dimensional array. For really large recordsets this is the way to go. It is much faster than looping through the recordset.

GetRows' basic syntax is:

variable = Recordset.GetRows([Rows] , [Start] , [Fields])

The parameters are optional, meaning if you don't pass any parameters variable = RS.GetRows() then all fields are stored in the array.

- Rows : number of rows inserted into the array.
- Start : think of it as a bookmark. this is the beginning row. default is the first row.
- Fields : used to specify a field name.

Code:
<%@ Language=VBScript %> <% Dim MyArray, MyConn, RS, i Set MyConn=Server.CreateObject("ADODB.Connection") MyConn.Open "Provider=SQLOLEDB;Data Source= NS3.domain.net;UID=username;PWD=password;DATABASE= demo.mdb" SQL = "Select col1, col2, col3, col4 From tblCustomers" Set RS = MyConn.Execute(SQL) 'Insert the data into the array MyArray=RS.GetRows 'clean up RS.Close MyConn.Close Set RS = Nothing Set MyConn = Nothing 'Now loop through the array (much faster than looping through a recordset) and display the contents of the array For i=0 to UBound(MyArray,2) Response.Write "First Column = " & MyArray(0,i) & "<br>" Response.Write "Second Column = " & MyArray(1,i) & "<br>" Response.Write "Third Column = " & MyArray(2,i) & "<br>" Response.Write "Fourth Column = " & MyArray(3,i) & "<p>" Next %>


Only one drawback: you won't be allowed to use the RecordSet features, such as .UpDate, .Delete, etc... However, and most importantly, this is a great way to display pure data. And it is SO much faster!

Last edited by admin : 08-05-2004 at 02:20 AM.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 02:41 AM.



Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All content Copyright ©1999 - 2010, Programmers Resource, unless otherwise noted.