Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Dealing with Arrays
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

redbrad0
Advanced Member

USA
3725 Posts

Posted - 26 April 2001 :  14:15:23  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
I have never delt with arrays and trying to learn as i try and build a shopping cart app. Can someone please try and help me understand why i am getting this error message...


Microsoft VBScript runtime error '800a000d'

Type mismatch

/exhibitparts/config/inc_functions.asp, line 35


Below is the line on 35...

arrProdQty = Session("ProdQty")

Session("ProdQty") is holding an array which i check with the function IsArray.

What i am doing is storing the info into the array, saving it to a session object (which works) then taking the session object and putting it back into and variable to work with.

any help?



Brad

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 26 April 2001 :  19:29:49  Show Profile  Visit HuwR's Homepage
I think the problem is that even though IsArray tells you that session("ProdQty") is an array, when you do something like this

MyVar = session("prodqty") myVAr is a string

try this, don't know wether it would work
array(myVar) = session("prodqty").

You could also use the dictionary object if this is available on your server, it is useful for storing arrays.


Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 26 April 2001 :  19:39:05  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Ok i got this problem fixed, now here is my problem...

I am saying my data to an array and retrieving that array on another page.

Here is the code i use to add it to the array...

arrCart(pCartIndex,0) = strProdID

pCartIndex is the number of Array it gets inserted it into. Example 1, 2, 3, 4, etc..

I retrieve the Array on the next page and loop thru the items by this code...

for f=0 to pCartIndex-1
strSessionProductID = session("myCart")(f,0)
Response.Write strSessionProductID & "<br>"
next

is their anything special about arrays? i have been reading and cant seem to locate whats wrong. if anyone can help ill show them the two files that use this code cause i really need it done.



Brad
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 26 April 2001 :  19:53:34  Show Profile  Visit HuwR's Homepage
what is the error you are getting?

Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 26 April 2001 :  21:26:13  Show Profile
You should copy the array out of the Session collection to a local variable before iterating through it.


======
Doug G
======
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 27 April 2001 :  12:01:47  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Well I am not really getting an error. If you want to view the shopping cart goto

http://www.exhibitparts.com/exhibitparts/store/category.asp?cag_id=1

If you add one product, everything works fine. Add another one, it makes the first one go empty and adds the other one so it works. add another one, it deleted the 2nd, it erases the text and adds the correct data for the 3rd one. if you keep adding products i think you can understand but i only have 2 procuts in it so far.

Brad
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 28 April 2001 :  01:41:22  Show Profile  Visit Gremlin's Homepage
Just a tip on Arrays

When stored in a Session object they can-not be modified. You must first retrieve them, then modify, then put back into Session if required. ie

Dim MyArray(x,x)
MyArray(0,0) = Value 1
MyArray(1,0) = Value 2
Session("StoredArray") = MyArray 'Saves the Array as Session Variable called "StoredArray"

MyArray = Session("StoredArray") ' to retrieve the Array

If you'd like to post some more code, or even email it to me, I'd be happy to take a look at it for you.


Edited by - Gremlin on 28 April 2001 06:16:30
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 28 April 2001 :  19:04:04  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
I got it to work, thansk guys for all your help

Brad
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07