View Full Version : Convert Object to a String

07-25-2007, 12:43 PM
I want to store a Request.Form/QueryString value in a Session object...

Session(qnum+'OS') = Request.Form("sOption");

But it shows me this error:

Session object error 'ASP 0168 : 80004005'

Disallowed object use

/papers/maths/CheckAnswer.asp, line 8

An intrinsic object cannot be stored within the Session object.

I've tried the .Item at the end of Request.Form/QueryString, but it is not retrieving the value of the field.

Never mind the i

07-25-2007, 12:58 PM
It's the Session(qnum+'OS') that's causing the problem.

You need to make it

Session("OS") = Request.form("sOption") + qnum


Session("OS") = qnum + Request.form("sOption")

ASP is throwing the error because you cannot create session names dynamically.

07-25-2007, 01:31 PM
Am I being daft or do you not surely also need to change the "+" addition operator for a "&" concatenation operator? Or does VBScript work with both? TBH I've never tried....

07-25-2007, 02:01 PM
Well, it looks as though (by code) that s/he is trying to add qnum and Request.form("sOption"), which is why s/he is using the '+' operand.

But you are correct -- concatenation in ASP is '&', not '+'. You cannot use '+' in ASP except for mathematical addition.

07-25-2007, 02:59 PM
Actually in VB you can concatenate with BOTH the + and & operands. However, It is bad practice to use + as a concatenation operator because it makes the code harder to read for the next person.