473,395 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 12726
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: firegun9 | last post by:
Hello all, After looking for the solution for a while in the group, I know this is not possible in C++. So I just say my problme here. The input file is: dev1 1 1 dev2 0 0 0 6 There is a...
4
by: Tim.D | last post by:
People, I've ventured into the wonderful world of Stored Procedures. My first experience has been relatively successful however I am stuck on using host variables to specifiy actualy table or...
5
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
3
by: Mark S. | last post by:
As I understand it, C# doesn't offer dynamic variable names. Below is my attempted workaround. Is what I'm doing possible? FYI, I already read all the "why in the world do you need dynamic...
5
by: Rolf Mander | last post by:
Hi, I need to use dynamic variable names but for objects. As you know something like that works fine: $variable="content"; $part="able"; echo ${"vari".$part}; // gives out content but i...
7
by: DavidSeck.com | last post by:
Hi guys, first post :) my question: is it possible to have dynamic variable names, I mean something like this: for($i=0;$i<x;$i++){ $y_$i = blabla; }
0
JamieHowarth0
by: JamieHowarth0 | last post by:
I'm about to set up a new website, powered by DotNetNuke (my favourite CMS at the moment, mainly because it's free), and I want to install a Counter-Strike game server onto the same machine. I also...
26
by: Aaron \Castironpi\ Brady | last post by:
Hello all, To me, this is a somewhat unintuitive behavior. I want to discuss the parts of it I don't understand. .... f= lambda: n .... 9 9
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.