473,545 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(strVarI d) = 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 12739
Ugh, why? Use an array.

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


"Jas" <no****@nomail. com> wrote in message
news:OE******** ******@TK2MSFTN GP12.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(strVarI d) = 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***@TRASHasp faq.com> wrote in message
news:u7******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP12.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(strVarI d) = 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("minYea r") = minYear
session("maxYea r") = maxYear
session("years" ) = years
end if

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


"Jas" <no****@nomail. com> wrote in message
news:uY******** ******@TK2MSFTN GP10.phx.gbl...
can you give an example aaron

thanks

"Aaron Bertrand [MVP]" <aa***@TRASHasp faq.com> wrote in message
news:u7******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP12.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(strVarI d) = 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
3074
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 base class "Base" and two derivated classes "dev1" and
4
13051
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 column names in a FROM clause. After many hours or reading all manner of manuals I've discovered it appears this is not possible and that in order to...
5
3742
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 believe the problem centers around my handling of strings, arrays, pointers and dynamic memory allocation. Here is the problem I'm trying to solve: ...
7
3374
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 either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the...
3
1937
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 variabale names" comments by other posters, if you are kind enough to post a reply please either say it's impossible, or it is possible if I did x. TIA ...
5
5060
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 need to use a database object after a mysql query something like that
7
2404
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
7623
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 want a little module that will show visitors to my site how many people are logged onto the CS server and some basic stats. Sounds simple right? ...
26
2780
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
7459
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7749
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5965
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5322
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3444
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1871
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
695
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.