views:

123

answers:

1

Here's my ASP Classic:

set irs  = recordset(sql,PageDB)            
    if not irs.eof then

        dim new_list
        new_list = ""

        do while not irs.eof

            'Add irs("name") to new_list and seperate by comma      

        irs.movenext

        loop

    end if

kill(irs)

How would I add irs(name) to new_list and seperate by a comma?

+1  A: 
set irs  = recordset(sql,PageDB)            
    if not irs.eof then

        dim new_list
        new_list = ""

        do while not irs.eof

            new_list = new_list & irs("name") & ","     

        irs.movenext

        loop

        new_list = left(new_list, len(new_list)-1)

    end if

kill(irs)
Tom Gullen
Perfect - Thank you Tom!
Sam
The script will throw an error if there are no records in the DB, so you might want to check for that before stripping the final comma from the end.
Tom Gullen
I slightly cleaner implementation would be to check irs.eof after irs.movenext, and then append the "," if still false. For a faster solution you may want to use irs.GetString()
thomask
The fastest solution would load the recordset into an array with getrows then loop the array set :)
Tom Gullen