|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Type mismatch
I pass session variables in a querystring to another page, which increments an array and adds them to it. This had been working absolutley fine on my local machine and I uploaded the scripts to a remote server. Everything worked fine (and still does) on the remote server.
I then decided to try opening the script that receives the querystring in a popup with javascript window.open, to display the results in the popup instead of a full new page as before. When I tried this I got a Type Mismatch on the receiving page. I hadn't changed any of the code in any of the pages apart from calling the receiving page with window.open, so I thought it just didn't like being called/opened that way. So I removed the window.open and went back to the old way - and I still get the Type Mismatch. I couldn't see why it was throwing this now, so I downloaded the scripts from the remote server (which work fine) to my local machine and I still get the Type Mismatch on the local machine. I tried stopping and starting IIS and then rebooting, but to no avail. It still works remotely but not locally. The mismatch is occuring apparently between the String I'm trying to add to the array and the array index (which is also a session variable): Here's the code in question: pitem = Request.QueryString("fpItem") Dim tmpArray tmpArray = Session("arrItem") tmpArray(Session("indx")) = pitem Session("arrItem") = tmpArray Session("indx") = Session("indx") + 1 The Type Mismatch is occuring here: tmpArray(Session("indx")) = pitem If this shouldn't have worked some reason before, that's OK, but why does it still work fien on the remote server? Neddles to say, any suggestions would be greatly appreciated! |
|
#2
|
|||
|
|||
|
i think Session will return a variant data type which is used rather often (unfortunately) in ASP. however, an index of an array is an Integer so you should always explicitly convert to the data type you need.
Code:
tmpArray(CInt(Session("indx"))) = pitem
see if that solves the problem. if not make sure that Session("indx") has a value.
__________________
Programmer's Corner |
|
#3
|
|||
|
|||
|
I tried CInt to explicitely convert the array index to integer, but still got the Type mismatch. I checked Session("indx") and found that in fact it contained nothing. But your right about explicitely setting varibale types to make for cleaner code as a habit.
Apparently I have an initialization problem. I initialize it in Global.asa with: Sub Session_OnStart Session("indx")=0 ... End Sub This has always worked before. Can I cast a type for the session variable here? Thank you ! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Type mismatch |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|