Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 12th, 2004, 03:20 PM
Friend of Wrox
 
Join Date: Jul 2003
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
   MyArray=rsCategory("QueryCategory")
rsCategory.movenext
loop

Thank you for all your help!

Leon

 
Old May 13th, 2004, 02:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 13th, 2004, 01:25 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This solution helps! Thanks again Imar!

Leon






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.