Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 12th, 2004, 03:20 PM
Friend of Wrox
Join Date: Jul 2003
Location: , , .
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recordset Into Array ~ How do I do it?

Hi All,

How do I put my recordset into an Array? If the "do while" does not work, can I use the "for....loop?" If so, how do I do so? Please read my current codes below. IT DOES NOT WORK!
When i code in MyArray=rsCategory("QueryCategory") to try to get the values into the array, I get an error message.

'Get recordset
set rsCategory=Server.CreateObject("ADODB.recordset")
SQL1="SELECT sCategory, sDescription, sValue, menu1relation, QueryCategory FROM sCategory where sCategory= '" & sCategory & "'"
rsCategory.Open SQL1, sConnection

Dim MyArray
MyArray = array()
do while NOT rsCategory.EOF

Thank you for all your help!


Reply With Quote
  #2 (permalink)  
Old May 13th, 2004, 02:37 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

You're not actually putting your records in an array, you are assigning the value from the recordset to a variable. So, at this point:

MyArray = rsCategory("QueryCategory")

the variable MyArray holds just the name of one category. After the next loop, it holds the name of the next category.

You could create an array and use an indexer / loopcounter to store the results (e.g. MyArray(i) = rsCategory("QueryCategory")), but I think you're much better off using the build-in GetRows method, like this:

MyArray = rsCategory.GetRows()

Check out this page for more info: http://msdn.microsoft.com/library/de...mthgetrows.asp


Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old May 13th, 2004, 01:25 PM
Friend of Wrox
Join Date: Jul 2003
Location: , , .
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts

This solution helps! Thanks again Imar!


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
converting recordset to array? carnevil00 Access VBA 8 October 2nd, 2006 02:43 PM
Recordset into array foddie Beginning PHP 2 August 8th, 2006 08:36 AM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM
Converting recordset to an array satellite360 Classic ASP Basics 1 February 3rd, 2004 05:41 AM

All times are GMT -4. The time now is 05:16 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.