469,352 Members | 1,697 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Dynamic Variable Names

Jas
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
Jul 19 '05 #1
4 12444
Ugh, why? Use an array.

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


"Jas" <no****@nomail.com> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #2
Jas
can you give an example aaron

thanks

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:u7**************@TK2MSFTNGP09.phx.gbl...
Ugh, why? Use an array.

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


"Jas" <no****@nomail.com> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
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


Jul 19 '05 #3
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" <no****@nomail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
can you give an example aaron

thanks

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:u7**************@TK2MSFTNGP09.phx.gbl...
Ugh, why? Use an array.

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


"Jas" <no****@nomail.com> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
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



Jul 19 '05 #4
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!
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by firegun9 | last post: by
5 posts views Thread by Rolf Mander | last post: by
7 posts views Thread by DavidSeck.com | last post: by
26 posts views Thread by Aaron \Castironpi\ Brady | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.