Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Recordset Column Names to Variables
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Recordset Column Names to Variables

 Post Reply Post Reply
Author
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post Topic: Recordset Column Names to Variables
    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

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2003 at 2:56pm
Why would you want to create variable that you didn't know the name for beforehand?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.