Solved

Type mismatch line 0

Posted on 2004-03-30
21
1,293 Views
Last Modified: 2012-08-14
I have this in my ASP page:

session("test") = "Testing"
session("groupselectedname") = groupselectedname
Response.Write session("test")
Response.Write session("groupselectedname")

The last line returns this error:

Testing
Response object error 'ASP 0106 : 80020005'

Type Mismatch

ASPDisplay.asp, line 0
An unhandled data type was encountered.

If my variable prints out fine, why does the second one bomb out?  I know, your next question is "what is the value of groupselectedname?"  I don't know, any attempt to display or convert its value returns the above error.  Why can't I do anything with that value?

Thanks!
0
Comment
Question by:MIKEV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 5
  • +3
21 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 10715047
Well where do you set the value of groupselectedname?  You have to have some idea of what's in it?

Response.write "Value: " & groupselectedname

Do that give an error too?
0
 

Author Comment

by:MIKEV
ID: 10715126
Same error.
0
 

Author Comment

by:MIKEV
ID: 10715193
Here's the line that assigns it:

groupselectedname = session("groupselectedname")

if I do right after it:

response.write session("groupselectedname") ' or
response.write groupselectedname

I get the above error each time.  The code takes the current selection, modifies it and then re-assigns it back to session memory.  Later on in the code it does the opposite, as above.  No errors are ever returned from the code unless I try to print any of the values.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 11

Expert Comment

by:mouatts
ID: 10715208
Can you do a
response.write varType(groupselectedname)
I suspect that groupselectedname is an object or binary data (9, 12,13 or 17 will be displayed if I am right.

Steve
0
 
LVL 11

Expert Comment

by:mouatts
ID: 10715226
or 0 if it is empty and 1 if it is null.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 10715256
Does ity happen with any session variables or just this one ?
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10715278
So where are you setting session("groupselectedname") initially?  Looks like your setting them back and forth, don't understand!
0
 
LVL 1

Assisted Solution

by:sknight
sknight earned 50 total points
ID: 10715290
I'd recommend dimming your variables first:

Dim groupselectedname
response.write(groupselectedname)
response.end
session("test") = "Testing"
session("groupselectedname") = groupselectedname
Response.Write session("test")
Response.Write session("groupselectedname")

Try that code, it should simply write the value of groupselectedname to the screen, at least you know what the value is, and you can sort out any datamismatches from there.  The test session is a static bit of text, however the groupselectedname session is a variable, and likelyhood is, it might be empty.
0
 

Author Comment

by:MIKEV
ID: 10715384
mouatts:  When I add that line it prints '8204'. (?)
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10715415
An array?  How'd it become an array?
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10715427
Try this:

Response.write "Value: " & groupselectedname(0)
0
 
LVL 11

Expert Comment

by:mouatts
ID: 10715431
Worse still its an array of varients.

Steve
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10715432
OR:

Response.write "Value: " & session("groupselectedname")(0)
0
 

Author Comment

by:MIKEV
ID: 10715570
Response.write "Value: " & session("groupselectedname")(0)

returns:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'session(...)'

/ebas/error.asp, line 60


How do you print an element from a session array variable?  These don't work:

session("oldselectedname")(0)
session("oldselectedname(0)")

Any other guesses?  (thx guys)
0
 

Author Comment

by:MIKEV
ID: 10715669
This doesn't work:

Dim Myselection
Myselection = session("groupselectedname")

response.write myselection(1) ' Type mismatch

for a=1 to 8
    response.write a & ":" & myselection(a) & "<BR>" ' type mismatch
next
0
 
LVL 31

Assisted Solution

by:alorentz
alorentz earned 200 total points
ID: 10715677
This is how:
Response.write "Value: " & session("groupselectedname")(0)
 
But it won't let you access it as an array.

However, where are you assigning either of these variables to an actual value.  In your examples yuo're just setting to each other, without ever putting in a value.

At least do this:

groupselectedname = ""

session("test") = "Testing"
session("groupselectedname") = groupselectedname
Response.Write session("test")
Response.Write session("groupselectedname")
0
 
LVL 11

Accepted Solution

by:
mouatts earned 200 total points
ID: 10715696
It won't work because its a varient as I mentioned earlier. We need to look at where groupselectedname is first initialised.
Steve
0
 
LVL 1

Expert Comment

by:sknight
ID: 10715704
Can you show the code that originally creates the value(s) for groupselectedname ?
0
 
LVL 11

Expert Comment

by:mouatts
ID: 10715713
My comment refers to MIKEVs comment not alorentz's
0
 
LVL 28

Assisted Solution

by:sybe
sybe earned 50 total points
ID: 10722037
the variable "groupselectedname"  is an array.
But it can be an array of anything, it can be an array of arrays or an arry of objects, or a multi-dimensional array. You have to find out what it's elements are.

To find it's dimension, you can use this function:

<%
Function GetArrayDimension(ByVal aArray, ByVal iMax)
    Dim iCount, iTest
    On Error Resume Next
    For iCount = 1 To iMax
        iTest = UBound(aArray,iCount)
        If Err Then Exit For
    Next
    GetArrayDimension = iCount -1
    Err.Clear
End Function
%>
0
 

Author Comment

by:MIKEV
ID: 10724983
The real problem is that this entire app was written by a dumbass.  No variable initializations, no code comments and a train of logic that defies.... logic.  He stores dates in text fields, making date based SQL queries more or less impossible.  It's not that he doesn't know how to program, he's been doing it for 40 years and programs like it's still 40 years ago.

However, thanks to all for the suggestions, you did help me understand the syntax and structure he's attempting to use.  I'll split the points as best I can...

Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question