Error Displyaing Session Variables

J

Jerry

I'm using this code:

Dim strName
For Each strName in Session.Contents
Response.Write strName & " - " & Session.Contents(strName) & "<BR>"
Next

If I only do a response.write strName, it shows all the session names
but when I include the session.contents it gives me the following
error:

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment

I've been to http://www.aspfaq.com/show.asp?id=2373 and it talks about
using ADODB.Recordset but I'm not accessing data on this page.

Any ideas why this is happening?

Thanks,
 
M

Mike Brind

Jerry said:
I'm using this code:

Dim strName
For Each strName in Session.Contents
Response.Write strName & " - " & Session.Contents(strName) & "<BR>"
Next

If I only do a response.write strName, it shows all the session names
but when I include the session.contents it gives me the following
error:

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment

I've been to http://www.aspfaq.com/show.asp?id=2373 and it talks about
using ADODB.Recordset but I'm not accessing data on this page.

Any ideas why this is happening?

http://www.aspfaq.com/show.asp?id=2524
 
J

Jerry

Mike said:

Thanks Mike.

I tried the example and I get the following error:

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'Item'

So I added Dim Item and I get the original error messgae again:

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment
 
A

Anthony Jones

Jerry said:
Thanks Mike.

I tried the example and I get the following error:

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'Item'

So I added Dim Item and I get the original error messgae again:

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment

The code you have posted is correct assuming that Session and Response are
what we think they are and it is this code that is actually producing the
error and not something else.

Which version of IIS are we talking about?
 
J

Jerry

Anthony said:
The code you have posted is correct assuming that Session and Response are
what we think they are and it is this code that is actually producing the
error and not something else.

Which version of IIS are we talking about?

IIS 5.1

If I remove the session(Item) part, it will list the session names.

Dim Item
For Each Item in Session.Contents
Response.Write Item & "<BR>"
Next
 
B

Bob Barrows [MVP]

Jerry said:
I'm using this code:

Dim strName
For Each strName in Session.Contents
Response.Write strName & " - " & Session.Contents(strName) & "<BR>"
Next

If I only do a response.write strName, it shows all the session names
but when I include the session.contents it gives me the following
error:

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment

I've been to http://www.aspfaq.com/show.asp?id=2373 and it talks about
using ADODB.Recordset but I'm not accessing data on this page.

Any ideas why this is happening?

Thanks,

I've never used Session.Contents, but it should work. This is what I always
do:

For Each strName in Session
Response.Write strName & " - " & Session(strName) & "<BR>"
Next


Anyways, if you create a page containing only the snip of code you've posted
above, will the error occur?
 
J

Jerry

Bob said:
I've never used Session.Contents, but it should work. This is what I always
do:

For Each strName in Session
Response.Write strName & " - " & Session(strName) & "<BR>"
Next


Anyways, if you create a page containing only the snip of code you've posted
above, will the error occur?

Yes, an ASP page with only the following:
<%
Dim Item
For Each Item in Session.Contents
Response.Write Item & " - " & Session(Item) & "<BR>"
Next
%>
produces the same error.

If I remove the .Contents then I get the following error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method
/trs/test.asp, line 3
 
M

Mike Brind

Jerry said:
Yes, an ASP page with only the following:
<%
Dim Item
For Each Item in Session.Contents
Response.Write Item & " - " & Session(Item) & "<BR>"
Next
%>
produces the same error.

If I remove the .Contents then I get the following error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method
/trs/test.asp, line 3

Try:

Dim x
For Each x in Session.Contents
Response.Write x & " - " & Session(x) & "<BR>"
Next
%>

Just a theory, but Item is a keyword in VBScript. That might be the
cause of the error.
 
J

Jerry

Mike said:
Try:

Dim x
For Each x in Session.Contents
Response.Write x & " - " & Session(x) & "<BR>"
Next
%>

Just a theory, but Item is a keyword in VBScript. That might be the
cause of the error.

Same error. I was initially using strName instead of Item but saw Item
in an example.
 
B

Bob Barrows [MVP]

Jerry said:
Yes, an ASP page with only the following:
<%
Dim Item
For Each Item in Session.Contents
Response.Write Item & " - " & Session(Item) & "<BR>"
Next
%>
produces the same error.

If I remove the .Contents then I get the following error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method
/trs/test.asp, line 3

I was just able to reproduce your error by using:
for each key in session.Contents
Response.Write "<BR>" & key & ": " & session.contents(key)
next

The error went away when I changed it to:
for each key in session.Contents
Response.Write "<BR>" & key & ": " & session(key)
next
 
J

Jerry

Bob said:
I was just able to reproduce your error by using:
for each key in session.Contents
Response.Write "<BR>" & key & ": " & session.contents(key)
next

The error went away when I changed it to:
for each key in session.Contents
Response.Write "<BR>" & key & ": " & session(key)
next

Thanks Bob, I'll try that Monday morning and see how it works!
 
J

Jerry

Bob said:
I was just able to reproduce your error by using:
for each key in session.Contents
Response.Write "<BR>" & key & ": " & session.contents(key)
next

The error went away when I changed it to:
for each key in session.Contents
Response.Write "<BR>" & key & ": " & session(key)
next

Sorry for the delayed response. This does not work either.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top