Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1403
  • Last Modified:

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

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
aaron63
Asked:
aaron63
  • 3
  • 3
  • 3
1 Solution
 
rg20Commented:
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
 
aaron63Author Commented:
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
 
rg20Commented:
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
Industry Leaders: 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!

 
jkdt0077Commented:
When you create a variable with varName(x) then you are creating an array. Is this what you are intending?
0
 
jkdt0077Commented:
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
 
rg20Commented:
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
 
aaron63Author Commented:
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
 
jkdt0077Commented:
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
 
aaron63Author Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now