Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Dynamic Variable Names

Reply
Thread Tools

Dynamic Variable Names

 
 
Jas
Guest
Posts: n/a
 
      02-10-2004
Hi All

I guess I should just have tried this to see if it works but I don't have
access to a machine running IIS and can't test it and I am itching for an
answer.

I want to use dynamic variable names in one of my pages.

I store a field called year in one of my table. For each year I want to
create a session variable for that year name perhaphs like the code below.

While not rs.eof
strVarId = strVarId & rs("year")
session(strVarId) = True
rs.movenext
Wend

the value in the recordset will be

2002
2003
2004
2005

hence I want 4 session variables like

strVarId2002
strVarId2003
strVarId2004
strVarId2005

Will this work?

Thanks

Jas


 
Reply With Quote
 
 
 
 
Jas
Guest
Posts: n/a
 
      02-10-2004
can you give an example aaron

thanks

"Aaron Bertrand [MVP]" <(E-Mail Removed)> wrote in message
news:u7PiZ#(E-Mail Removed)...
> Ugh, why? Use an array.
>
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>
>
>
> "Jas" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi All
> >
> > I guess I should just have tried this to see if it works but I don't

have
> > access to a machine running IIS and can't test it and I am itching for

an
> > answer.
> >
> > I want to use dynamic variable names in one of my pages.
> >
> > I store a field called year in one of my table. For each year I want to
> > create a session variable for that year name perhaphs like the code

below.
> >
> > While not rs.eof
> > strVarId = strVarId & rs("year")
> > session(strVarId) = True
> > rs.movenext
> > Wend
> >
> > the value in the recordset will be
> >
> > 2002
> > 2003
> > 2004
> > 2005
> >
> > hence I want 4 session variables like
> >
> > strVarId2002
> > strVarId2003
> > strVarId2004
> > strVarId2005
> >
> > Will this work?
> >
> > Thanks
> >
> > Jas
> >
> >

>
>



 
Reply With Quote
 
 
 
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      02-10-2004
Ugh, why? Use an array.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"Jas" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All
>
> I guess I should just have tried this to see if it works but I don't have
> access to a machine running IIS and can't test it and I am itching for an
> answer.
>
> I want to use dynamic variable names in one of my pages.
>
> I store a field called year in one of my table. For each year I want to
> create a session variable for that year name perhaphs like the code below.
>
> While not rs.eof
> strVarId = strVarId & rs("year")
> session(strVarId) = True
> rs.movenext
> Wend
>
> the value in the recordset will be
>
> 2002
> 2003
> 2004
> 2005
>
> hence I want 4 session variables like
>
> strVarId2002
> strVarId2003
> strVarId2004
> strVarId2005
>
> Will this work?
>
> Thanks
>
> Jas
>
>



 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      02-10-2004
if not rs.eof then
minYear = 2099
maxYear = 0
dim years(2010) ' how high?
' ...
do while not rs.eof
if minYear > rs("year") then minYear = rs("year")
if maxYear < rs("year") then maxYear = rs("year")
years(rs("year")) = True
rs.movenext
loop
session("minYear") = minYear
session("maxYear") = maxYear
session("years") = years
end if

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"Jas" <(E-Mail Removed)> wrote in message
news:uY#(E-Mail Removed)...
> can you give an example aaron
>
> thanks
>
> "Aaron Bertrand [MVP]" <(E-Mail Removed)> wrote in message
> news:u7PiZ#(E-Mail Removed)...
> > Ugh, why? Use an array.
> >
> > --
> > Aaron Bertrand
> > SQL Server MVP
> > http://www.aspfaq.com/
> >
> >
> >
> >
> > "Jas" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hi All
> > >
> > > I guess I should just have tried this to see if it works but I don't

> have
> > > access to a machine running IIS and can't test it and I am itching for

> an
> > > answer.
> > >
> > > I want to use dynamic variable names in one of my pages.
> > >
> > > I store a field called year in one of my table. For each year I want

to
> > > create a session variable for that year name perhaphs like the code

> below.
> > >
> > > While not rs.eof
> > > strVarId = strVarId & rs("year")
> > > session(strVarId) = True
> > > rs.movenext
> > > Wend
> > >
> > > the value in the recordset will be
> > >
> > > 2002
> > > 2003
> > > 2004
> > > 2005
> > >
> > > hence I want 4 session variables like
> > >
> > > strVarId2002
> > > strVarId2003
> > > strVarId2004
> > > strVarId2005
> > >
> > > Will this work?
> > >
> > > Thanks
> > >
> > > Jas
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Bullschmidt
Guest
Posts: n/a
 
      02-12-2004
Using the Eval and Execute Functions - 3/3/2000
http://www.4guysfromrolla.com/webtech/030300-1.shtml

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic variable names without EVAL - NEWBIE jason@cyberpine.com ASP .Net 2 07-15-2010 02:39 PM
Re: Dynamic variable names Steve Holden Python 0 02-07-2010 01:31 PM
dynamic variable names or using a variable as another's name Peter Buckley Ruby 5 02-27-2009 06:05 PM
checking for mis-spelled variable names / function names News123 Python 2 11-26-2008 12:37 AM
confusion between global names and instantiated object variable names wanwan Python 3 10-14-2005 09:46 PM



Advertisments