473,385 Members | 1,351 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,385 software developers and data experts.

Session Variable - array problem

Hi,

I need to create an array with a session variable.

According to thebook I'm using, the following should work, but if fails:

for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a
single session variable

Any suggestions where I'm going wrong.

Many thansk

NEIL

Jul 22 '05 #1
3 2933
"Neil Jarman" wrote ...
for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a
single session variable

Any suggestions where I'm going wrong.


Hi Neil,

Not saying you're wrong - as I've not used Session.Contents before - but I
didn't see an example of its use the way you've tried to use it here:

http://www.w3schools.com/asp/asp_sessions.asp

(not suggesting this is the entire scope of this listed here mind!)..

I was able to get your example to work though when I changed it to read:

<%

for each key in request.QueryString

if left(key,6) = "cboRun" then

iIndex = cint(mid (key,7))

session.Contents("iRunNo") = iIndex ' this is the line I
changed

end if

next

Response.Write "And finally: " & Session("iRunNo")

%>

I'm sure you probably have anyway in your application - but obviously this
example doesn't have any kind of error catching around cboRun if the
querystring doesn't come back with what you expect...ie, if I changed it to
: cboRunMONKEY17 - suddenly there are errors where trying to cInt
stuff....just thought it worth mentioning...

Regards

Rob

Jul 22 '05 #2
To save an array in a session variable you have to create the array as a
local variable first then put it into a session variable. To access it later
you have to put it into a local variable again.

(note: from memory, may need some adjustments)

dim aIn(), aOut
dim i, key, iIndex

redim aIn( request.querystring.count ) 'make array big enough to hold all
params

i = 0
for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
aIn(i) = iIndex ' could use aIn(iIndex)=iIndex if that is what is
needed
i = i + 1
end if
next
redim preserve aIn( i-1 ) 'adjust upper bound to match count of desired
params
Session("iRunNo") = aIn

aOut = Session("iRunNo")
for i = 0 to ubound(aOut)
response.Write(aOut(i) & "<br>")
Next

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Neil Jarman" <ne**@tNOiSPAMvPLEASEy.co.uk> wrote in message
news:cs*******************@news.demon.co.uk...
Hi,

I need to create an array with a session variable.

According to thebook I'm using, the following should work, but if fails:

for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a
single session variable

Any suggestions where I'm going wrong.

Many thansk

NEIL

Jul 22 '05 #3
Hi Mark,

Thanks for the help, I will test it tomorrow - typical that my book glossed
over that part!

Cheers,

NEIL
"Mark Schupp" <no******@email.net> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
To save an array in a session variable you have to create the array as a
local variable first then put it into a session variable. To access it later you have to put it into a local variable again.

(note: from memory, may need some adjustments)

dim aIn(), aOut
dim i, key, iIndex

redim aIn( request.querystring.count ) 'make array big enough to hold all
params

i = 0
for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
aIn(i) = iIndex ' could use aIn(iIndex)=iIndex if that is what is
needed
i = i + 1
end if
next
redim preserve aIn( i-1 ) 'adjust upper bound to match count of desired
params
Session("iRunNo") = aIn

aOut = Session("iRunNo")
for i = 0 to ubound(aOut)
response.Write(aOut(i) & "<br>")
Next

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Neil Jarman" <ne**@tNOiSPAMvPLEASEy.co.uk> wrote in message
news:cs*******************@news.demon.co.uk...
Hi,

I need to create an array with a session variable.

According to thebook I'm using, the following should work, but if fails:

for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a single session variable

Any suggestions where I'm going wrong.

Many thansk

NEIL


Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
1
by: Sean Pinto | last post by:
Ok, you all are going to have to bear with me on this one as it is kinda complicated to explain. I am implementing a company management suite that requires Role-Based authentiations (ie. users are...
1
by: s_m_b | last post by:
I am having a problem with a page that creates a treeview from a database, by reloading itself on each request for a new folder to be explored. The problem revolves around using an array to store...
7
by: Nicole | last post by:
Hi I'm trying to use a function to set a session variable. I have three files: The first file has: <?php session_start(); // This connects to the existing session ?> <html> <head>
9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
4
by: tma | last post by:
I'm trying to save code to a session object like the following: dim oAppList as arraylist dim oApp as someclass Code to manipulate oApp... .... .... oApplist.Add(oApp)...
3
by: Brad | last post by:
I am storing an array which contains about a dozen chracter items to a Session variable. Later, I need to use this array so I am doing the following: Dim eventTypes As String() =...
5
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers? Reference...
6
by: Vyoma | last post by:
This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I have been lurking around at several forums with regard to login and user authentication scripts and...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.