By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

can Session.Contents can be a string array?

P: n/a
Hello,

My script builds a list of files in a folder.
These files are stored in an 2-dimensional array, called "a_files".

To speed up the script, I don't want the filelist everytime being read on
the server.
Therefore I wanted to send the contents of a_files to a session variable.

However, with
Session.Contents("sFiles") = a_files

I get the following error message:
***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Is it impossible to store an array to a session var?
Is there another way to store the array somewhere in memory so it has not to
be rebuild everytime?

tia

bartp


--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee
Jul 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Do this:
Session("sFiles") = a_files

Bob Barriws

Bart Plessers (artabel) wrote:
Hello,

My script builds a list of files in a folder.
These files are stored in an 2-dimensional array, called "a_files".

To speed up the script, I don't want the filelist everytime being
read on the server.
Therefore I wanted to send the contents of a_files to a session
variable.

However, with
Session.Contents("sFiles") = a_files

I get the following error message:
***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Is it impossible to store an array to a session var?
Is there another way to store the array somewhere in memory so it has
not to be rebuild everytime?

tia

bartp

Jul 19 '05 #2

P: n/a
> "Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
news:#p**************@TK2MSFTNGP12.phx.gbl...
Therefore I wanted to send the contents of a_files to a session variable.

However, with
Session.Contents("sFiles") = a_files

I get the following error message:
***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Is it impossible to store an array to a session var?
Yes, you can.<%
Dim x(2)
x(0) = "a"
x(1) = "b"
x(2) = "c"

Session("arr") = x

Response.write Session("arr")(0)
Response.write Session("arr")(1)
Response.write Session("arr")(2)
%>

What is the rest of your code?
Is there another way to store the array somewhere in memory so it has not to be rebuild everytime?


A database is another option.

Ray at home

Jul 19 '05 #3

P: n/a

hmm,
you build the array in memory.

I have build the array in code:

'**********************************
Dim a_files()
i_dim = 3 'geeft het aantal gegevens aan per j in de array. Opgelet, indien
4 gegevens nodig, dan
i_name = 0 'gives posistion in array
i_size = 1 'gives posistion in array
i_type = 2 'gives posistion in array
i_date = 3 'gives posistion in array

j = 0
For each oFile in oFiles
ReDim Preserve a_files(i_dim,j)
a_files(i_name,j) = oFile.Name
a_files(i_size,j) = oFile.Size
a_files(i_type,j) = oFile.Type
a_files(i_date,j) = oFile.DateLastModified
j = j + 1
Next
'**********************************
Then I want to pass the a_files() to a session string

Can this also be done?
Syntax if?
tia

bartp

--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

"Ray at home" <myfirstname at lane 34 . komm> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
"Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message news:#p**************@TK2MSFTNGP12.phx.gbl...
Therefore I wanted to send the contents of a_files to a session variable.
However, with
Session.Contents("sFiles") = a_files

I get the following error message:
***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Is it impossible to store an array to a session var?


Yes, you can.<%
Dim x(2)
x(0) = "a"
x(1) = "b"
x(2) = "c"

Session("arr") = x

Response.write Session("arr")(0)
Response.write Session("arr")(1)
Response.write Session("arr")(2)
%>

What is the rest of your code?
Is there another way to store the array somewhere in memory so it has

not to
be rebuild everytime?


A database is another option.

Ray at home


Jul 19 '05 #4

P: n/a
An array is an array.
You can store it as an array in a session variable.

Bart Plessers (artabel) wrote:
hmm,
you build the array in memory.

I have build the array in code:

Jul 19 '05 #5

P: n/a
do you have any idea why i get the error

***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Session.Contents("sFiles") = a_files
Do I have do Dim the sFiles before?

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:eO**************@TK2MSFTNGP10.phx.gbl...
An array is an array.
You can store it as an array in a session variable.

Bart Plessers (artabel) wrote:
hmm,
you build the array in memory.

I have build the array in code:


Jul 19 '05 #6

P: n/a
I don't know. I've tried your code and do not get the error. Here is what I
tried:

Dim a_files()
i_dim = 3 'geeft het aantal gegevens aan per j in de array. Opgelet, indien
4 gegevens nodig, dan
i_name = 0 'gives posistion in array
i_size = 1 'gives posistion in array
i_type = 2 'gives posistion in array
i_date = 3 'gives posistion in array
set fso=Server.CreateObject("scripting.filesystemobjec t")
set oFldr = fso.GetFolder(server.MapPath("."))
set oFiles = oFldr.Files
j = 0
For each oFile in oFiles
ReDim Preserve a_files(i_dim,j)
a_files(i_name,j) = oFile.Name
a_files(i_size,j) = oFile.Size
a_files(i_type,j) = oFile.Type
a_files(i_date,j) = oFile.DateLastModified
j = j + 1
Next
Session.contents("arr") = a_files
for i = 0 to ubound(session("arr"),2)
for j = 0 to ubound(session("arr"),1)
Response.Write session("arr")(j,i) & "<BR>"
next
next

It seems like you don't have an array. Have you used IsArray to verify that
a_files is an array?

Bob Barrows

bart plessers wrote:
do you have any idea why i get the error

***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Session.Contents("sFiles") = a_files
Do I have do Dim the sFiles before?
"Bob Barrows" <re*******@yahoo.com> wrote in message
news:eO**************@TK2MSFTNGP10.phx.gbl...
An array is an array.
You can store it as an array in a session variable.

Bart Plessers (artabel) wrote:
hmm,
you build the array in memory.

I have build the array in code:

Jul 19 '05 #7

P: n/a
bob,
STUPID ME!!!!!!!!!

sorry to bother you with this.
The problem was that -for debugging- I had included a file "_debug.asp"
In this file, there was a line :

response.write(session("SFiles"))

just becaus SFiles was an array, the response.write could not handle
this.......
anyway,
your code pointed me to reconstruct the array, and not write it itself, so
it was very helpfull!

sorry to bother you
thanx again,

bartp

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:e8**************@TK2MSFTNGP10.phx.gbl...
I don't know. I've tried your code and do not get the error. Here is what I tried:

Dim a_files()
i_dim = 3 'geeft het aantal gegevens aan per j in de array. Opgelet, indien 4 gegevens nodig, dan
i_name = 0 'gives posistion in array
i_size = 1 'gives posistion in array
i_type = 2 'gives posistion in array
i_date = 3 'gives posistion in array
set fso=Server.CreateObject("scripting.filesystemobjec t")
set oFldr = fso.GetFolder(server.MapPath("."))
set oFiles = oFldr.Files
j = 0
For each oFile in oFiles
ReDim Preserve a_files(i_dim,j)
a_files(i_name,j) = oFile.Name
a_files(i_size,j) = oFile.Size
a_files(i_type,j) = oFile.Type
a_files(i_date,j) = oFile.DateLastModified
j = j + 1
Next
Session.contents("arr") = a_files
for i = 0 to ubound(session("arr"),2)
for j = 0 to ubound(session("arr"),1)
Response.Write session("arr")(j,i) & "<BR>"
next
next

It seems like you don't have an array. Have you used IsArray to verify that a_files is an array?

Bob Barrows

bart plessers wrote:
do you have any idea why i get the error

***********************
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered.
***********************

Session.Contents("sFiles") = a_files
Do I have do Dim the sFiles before?
"Bob Barrows" <re*******@yahoo.com> wrote in message
news:eO**************@TK2MSFTNGP10.phx.gbl...
An array is an array.
You can store it as an array in a session variable.

Bart Plessers (artabel) wrote:
hmm,
you build the array in memory.

I have build the array in code:


Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.