| 4GuysFromRolla.com : ASP FAQS : Arrays | ||||
|
| ||||
| Question: | How can I convert a Recordset into an array? Also, how can I convert an array into a Recordset? | |||
|
| ||||
| Answer: | Conceptually, a Recordset is nothing more than a glorified two-dimensional array. A Recordset consists of zero to many rows, each row having zero to many columns, just like a two-dimensional array. Specifically, each cell of a Recordset is a Field object, storing information like the name of the column, the value of the cell, the data type, the max length, the precision, whether or not the cell can contain a NULL value, etc. Using the GetRows() method of the Recordset object we can turn the contents of a Recordset into a two-dimensional array. Understand that this array contains less information that the Recordset. Only the values of each of the cells in the Recordset are stored in the array, information like the column's name, the data type, etc., are not stored in this array. You may be wondering why, exactly, one would want to use GetRows() as opposed to just looping through a Recordset. For a good read on the performance advantages of using GetRows(), be sure to read Why GetRows() is Best to Fetch Data.The complete technical syntax for GetRows() can be seen here. In its simplest form, all you need to do is open a Recordset object and then call GetRows():
That's all there is to it! At this point,
A live demo of using
An example of using this third parameter can be seen in the live demo. | |||
|
FAQ posted by Scott Mitchell at 6/14/2001 5:02:03 PM to the Arrays category. This FAQ has been viewed 238,089 times. | ||||
Copyright 2010 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers