Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 October 27th, 2004, 10:53 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to I loop through the items in a server object

I am trying to loop through a record set for items that meet certain criteria. Here's my code..

'CONNECT FROM THE PAGE TO THE DATA SOURCE

Dim theImgSource, Connect, requestrs, Query, id
Set Connect = server.CreateObject("ADODB.Connection")
Connect.ConnectionString = getConnectionStr("test")
Connect.open

'INSTANTIATE A CONTAINER FOR THE DESIRED DATA
Set rs = server.createobject ("adodb.recordset")
Query = "SELECT tblImgs.refForImage FROM tblImgs WHERE ((tblImgs.active)=True)"
rs.open Query, connect


'ASSIGN THE DATA TO THE VARIABLE ON THE PAGE
dim item
For Each item in rs
    Select Case imgName
        case "rmo1topimg"
            rmo1topimg = serverContainer("refForImage")
        case "rmo2topimg"
            rmo2topimg = serverContainer("refForImage")
    End Select
Next

%>

The line that throws an error is " For Each item in rs ". I seem to be incorrectly referring to the collection of records specified by the query. Ideas?

 
Old October 28th, 2004, 07:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Is there an items property? Usually, you have to access the collection that you are looping for. I believe it's fields for an ADODB.Recordset, so it would be:

for each item in rs.fields

If it's not fields, change fields to the proper collection param.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through 17 tables in RecordSet object didimichael C# 1 July 18th, 2008 06:53 AM
Work items tracking from Team Foundation Server? woojtii General .NET 0 April 4th, 2007 07:06 AM
Using Items.Context with Server.Transfer jazzcatone ASP.NET 1.0 and 1.1 Basics 0 August 27th, 2006 04:53 PM
For loop in SQL SERVER 2000 Asish SQL Server 2000 2 May 13th, 2004 04:25 AM
displaying 6 items only having 20 items Lakshmi KS VB Components 1 February 17th, 2004 10:34 AM





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