"Type mismatch: 'ubound' " Error

I have developed a shopping aplication which is working fine localy but when loaded in the main web server it says

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'ubound'

/subik/test2.asp, line 7

I presume it could be a problem in global.asa setting up

I need a solution immdly. Help please
vsriramAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jamestthomasConnect With a Mentor Commented:
First thing I notices is you are putting  info in nCartItemQtys then checking sCartItemNums
 see below:

nCartItemQtys = session("CartItemQtyArray")
  nNumCartItems = ubound(sCartItemNums)
 
Next, this propsoed answer;
If IsEmpty(sCartItemNums)  Then NumCartItems = 0 Else nNumCartItems = ubound(sCartItemNums)

misses the fact that you still do not know if you have an array.  to be safe I would go :

else
If IsArray( sCartItemNums) then
nNumCartItems = ubound(sCartItemNums)
0
 
xabiCommented:
Can you please post your line 7 of test.asp. Better the whole file.
xabi
0
 
vsriramAuthor Commented:
Hi xabi,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--#INCLUDE FILE="adovbs.inc"-->
<!--#INCLUDE FILE="procs.inc"-->

<%sCartItemNums = session("CartItemNumArray")
  nCartItemQtys = session("CartItemQtyArray")
  nNumCartItems = ubound(sCartItemNums)
  nThisItemIndex = 0
    sItemNo =Request.QueryString("itemno")
      
    if nNumCartItems > 0 then
      for i = 1 to nNumCartItems
        if ucase(sCartItemNums(i)) = sItemNo then
          nThisItemIndex = i
          exit for
        end if
      next
    end if
      
      if nThisItemIndex = 0 then
      nThisItemIndex = nNumCartItems + 1
      redim Preserve sCartItemNums(nThisItemIndex)
      redim Preserve nCartItemQtys(nThisItemIndex)
      sCartItemNums(nThisItemIndex) = sItemNo
      nCartItemQtys(nThisItemIndex) = 1
    else
        'n=request.form("tx2")
        'response.write(nThisItemIndex)
      nCartItemQtys(nThisItemIndex) = nCartItemQtys(nThisItemIndex) + 1
    end if

   session("CartItemNumArray") = sCartItemNums
   session("CartItemQtyArray")  = nCartItemQtys
   
   nNumCartItems = ubound(sCartItemNums)
 %>


Above code is the part in which the error occur.

Expecting a early solution.

Thank you

Sriram
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Yury_DelendikCommented:
Better if you write:

If IsEmpty(sCartItemNums)  Then NumCartItems = 0 Else nNumCartItems = ubound(sCartItemNums)
0
 
xabiCommented:
That's the answer.

xabi

PS: I was late ... :(
0
 
FRehmanCommented:
yury is right are you still in problem
0
 
xabiCommented:
Your problem is that the Session variable session("CartItemQtyArray")
 don't have anything or is not an Array. So when you try to get its size with "ubound" function you get the error.

xabi


0
 
freshmeatCommented:
and maybe the session timeout clean the session variable value?
ha, just guess, is it possible?
:D
0
 
HencahCommented:
and you had better always have default value for all of your session variables (as I learned from Wrox Prof ASP). In you global.asa may look like this:
 
sub Session_onStart
  if IsEmpty(Session(...)) then
     Session(..) = 0 ' default value
  end if
end sub

So in your asp pages you no need checking whether the Session variables is empty!

 
 
0
All Courses

From novice to tech pro — start learning today.