Print Page | Close Window

Recordset Column Names to Variables

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3693
Printed Date: 29 March 2026 at 11:56pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Recordset Column Names to Variables
Posted By: Gary
Subject: Recordset Column Names to Variables
Date Posted: 20 June 2003 at 7:16am

Not sure if this is possible....

Say I have a 3 column table with Name, Age, Gender. I can pull the column names by using Recordset.Fields(n).Name - eg rs.Fields(0).Name will be Name, rs.Fields(1) will be Age and rs.Fields(2) will be Gender.
Is it possible to loop through the Fields collection and create variables named with the .Name property and populated with the .Value property?

For example, in my case the following will be defined...
Name = 'Gary'
Age = 32
Gender = 'Male'

Thx




Replies:
Posted By: MorningZ
Date Posted: 20 June 2003 at 8:36am

i dont think you can "dynamically create variables" in Vbscript.. in fact, i've been doing ASP for almost 3 years now and never have seen that done

you could stash the name/value pair in something like an array



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Gary
Date Posted: 20 June 2003 at 9:09am

Thanks Morningz

Love the term 'stash' - makes it seem like I'm dealing with laundered money or narcotics !!!

On a serious note though, I would have thought that it would be possible, but I've torn most of my hair out by now. I'll most likely look to do as you suggested using the dictionary object to 'stash' the pairs.



Posted By: MorningZ
Date Posted: 20 June 2003 at 9:15am

i could try to help a bit further, but i have no idea as to "why" you need to do what you brought up... the fact is variables last just as long as a recordset does.. which is within the execution of the page...

no sense tearing your hair out over something that makes no sense to do



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: ljamal
Date Posted: 20 June 2003 at 2:56pm
Why would you want to create variable that you didn't know the name for beforehand?

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net