Solved

Type mismatch error '800a00d' in Session Variable with Array

Posted on 2009-07-09
9
1,347 Views
Last Modified: 2012-05-07
Background: We have a Web Application we use internally on a NT 4 box with IIS and SQL Server. Years ago I programmed a web application in Active Server Pages to access and collate this data into reports. Worked great for us for years and years. Note we are a relatively small office and I am not an IT guy. But I have an engineering degree, did a lot of reading, and was able to piece it all together.

Fast forward to the present. The NT 4 box is on its last leg so we upgraded to a Win Server 2003 with the later version of IIS.

There seems to be quite a different in coding. I am getting a type mismatch error with the following code (note worked fine on NT 4 box):

'In global.asa
ReDim TheSubject(16)
Session("SubjEnt") = TheSubject

'In subject1.asp

dim TempSubject(16) 'note I added the '(16)' to get rid of a previous type mismatch

TempSubject = Session("SubjEnt") 'here is where I get the type mismatch

Note the weird thing is I later have the line

Session("SubjEnt") = TempSubject

And I get no type mismatch with this line (if I comment out the other line). I can't tell if Session("SubjEnt") is getting all the values, however, because of the line commented out.


0
Comment
Question by:aaron63
[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
  • 3
  • 3
  • 3
9 Comments
 
LVL 9

Expert Comment

by:rg20
ID: 24820125
Would you be able to post the global.asa and subject pages?  It would help to see what the intent of the variables are.
0
 
LVL 1

Author Comment

by:aaron63
ID: 24822820
Sure I'll attach both files. And I appreciate the help. I will be traveling for work today so I probably won't reply to any new comments for a bit. I'm upping the points since people have to look through more code than I thought they'd have to.

If I could vent for a moment part of this application was done with Cold Fusion and upgrading from CF4 to CF8 went without a hitch. Everything seems backward compatible...why later versions of IIS don't like ASP code makes no sense to me.

I'm attaching global.asa as a code snippet and the subject1.asp file as an attached text file. Note I have to travel for work today so I probably won't be replying to any comments till over the weekend.
<!--#INCLUDE file="program/includes/SalesConstants.inc"--> 'Note this file just has a bunch of constants I use to manage arrays. I hard coded the lines with errors with numbers to see if the includes could be the problem.
 
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
 
 
Sub Application_OnStart
End Sub
 
Sub Session_OnStart
	ReDim TheSales(TotalChars, MaxStartUp)
	Session("SalesEnt") = TheSales
	ReDim TheSubject(16)
	Session("SubjEnt") = TheSubject
	ReDim TheAdjustments(TotalAdj, MaxStartUp)
	Session("AdjEnt") = TheAdjustments
	ReDim TheSubjectAdj(AdjPropTotal)
	Session("SubjAdj") = TheSubjectAdj
	Session("NumSales") = 0
	Session("NextPage") = ""
	Session("SaleIndex") = 0
	Session("CurrentMax") = MaxStartUp
	Session("ErrorString") = strCheckString
	Session("ListCheck") = ""
	Session("Pending") =  ""
	Session("SaletoImport") = 0
	Session("Error") = 0
	Session("LoggedOn") = FALSE
	Session("SubjectEntered") = FALSE
	Session("AdjustmentsEntered") = FALSE
	Session("UserName") = ""
	Session("UserID") = ""
	Session("Freepasses") = 0
    Session("reportprice") = 0
    Session("isadmin") = ""
    Session("AccountType") = ""
    Session("CompanyID") = ""
    Session("userNum") = 0
    Session("companyNum") = 0
    Session("ReportNum") = 0
    Session("ReportPrice")=0
    Session("linkone")=""
    Session("linktwo")=""
	Session("filepath1")=""
	Session("filepath2")=""
 
End Sub
 
Sub Session_OnEnd
	
End Sub
 
Sub Application_OnEnd
 
End Sub
</SCRIPT>

Open in new window

subject1.txt
SalesConstants.txt
0
 
LVL 9

Expert Comment

by:rg20
ID: 24823107
Ok heres what I see so far.  The session("SubjEnt") is a 2 dimentional array 25,10
ReDim TheSales(TotalChars, MaxStartUp)

You assign a session variable to it of "thesales"

Session("SalesEnt") = TheSales

In your asp page you are trying to assign it to a dingle dimensioned array
dim TempSubject(16) 'THIS IS THE VARIABLE THAT SEEMS TO BE PART OF THE PROBLEM
TempSubject = Session("SubjEnt") 'HERE IS WHERE I GET THE MISMATCH ERROR

So you either need to determine if you really need a 2 dimensional array, if so change temp subject to match
dim TempSubject(25,10)

or reduce the array in the global asa page.

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 7

Expert Comment

by:jkdt0077
ID: 24823143
When you create a variable with varName(x) then you are creating an array. Is this what you are intending?
0
 
LVL 7

Expert Comment

by:jkdt0077
ID: 24823178
rg20 is it not Session("SalesEnt") that is a 2 dimensional array and Session("SubjEnt") is a single array? Or have I read it wrong?

I do agree that it is an array issue though..
0
 
LVL 9

Expert Comment

by:rg20
ID: 24823388
your right, I misread it,

I do see a  file
program/jbasales/includes/SalesConstants.inc

Can you look in there and see if you have another redim tempsubj?

Also can you post the exact error message that you get?
0
 
LVL 1

Author Comment

by:aaron63
ID: 24831118
Thank you guys for your help. Sorry I didn't respond yesterday, but I was traveling for work.

jkd0077- Yes I intended to create an array with the statement. Maybe I better backtrack and talk about the error I had previous to this one.

In the ASP Classic that worked fine on the NT4 box the line:

dim TempSubject(16)

Was originally just

dim TempSubject

It was, however, always meant to be an array and worked as an array in ASP classic. In the original code the line

TempSubject = Session("SubjEnt")

did not cause any error. If I put the code back that way, however (without the '(16)') I get the following error:

Microsoft VBScript runtime  error '800a000d'

Type mismatch: 'TempSubject'

/program/jbasales/subject/subject1.asp, line 86

Line 86= tempAddress = TempSubject(0)

And if I commented that line out it would have a problem with the next line (which involved TempSubject(1). It was almost like it didn't know it was an array. Maybe TempSubject is acting like a 'pointer' because of the line: 'TempSubject = Session("SubjEnt")' like in C++? (another programming language I haven't touched in 10 years!) Has there been changes to allowed VB code? In that case what do I add to TempSubject if it is a pointer and I want to step through the array?

So when change the line back to

Dim TempSubject(16)

I get the following error:

Microsoft VBScript runtime  error '800a000d'

Type mismatch

/program/jbasales/subject/subject1.asp, line 32

And line 32 is: TempSubject = Session("SubjEnt")

So as soon as I change TempSubject to an array it does not like being set to equal 'Session("SubjEnt"), which is also an array. Perhaps when it is just a variant it is acting as a pointer? If that is the case what would I need to do to get it to step through the array? (if this is the problem at all).

Thanks for all the help!



At any rate if I change
0
 
LVL 7

Accepted Solution

by:
jkdt0077 earned 400 total points
ID: 24838151
This is a strange one, never really encountered this problem before. Been doing a little bit of testing and the following code snippet works for me (as an example).

So I'm declaring the first variable as an array and setting the values straight away. I then set the session variable to this created array. Then I create the tempSubject array (the same size etc) but I can only seem to output when explicitly setting each column in the array. If I don't do that then nothing outputs, which is strange.

Anyway, does this help at all?
<%
Dim theSubject(3)
theSubject(0) = "Test"
Session("subjEnt") = theSubject
Dim tempSubject(3)
tempSubject(0) = Session("subjEnt")(0)
Response.Write(tempSubject(0))
%>

Open in new window

0
 
LVL 1

Author Closing Comment

by:aaron63
ID: 31602846
Thank you. While this was not the exact solution it lead me to it. I ran your code and it worked fine. This got me to thinking that the global.asa was not running. And that turned out to be the problem. Did I mention I set up this on the original server 10 years ago and web programming is not my career? :)

Sorry for causing so much trouble and thanks again!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…

710 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