"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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you please post your line 7 of test.asp. Better the whole file.
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
    end if
      if nThisItemIndex = 0 then
      nThisItemIndex = nNumCartItems + 1
      redim Preserve sCartItemNums(nThisItemIndex)
      redim Preserve nCartItemQtys(nThisItemIndex)
      sCartItemNums(nThisItemIndex) = sItemNo
      nCartItemQtys(nThisItemIndex) = 1
      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

Better if you write:

If IsEmpty(sCartItemNums)  Then NumCartItems = 0 Else nNumCartItems = ubound(sCartItemNums)
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

That's the answer.


PS: I was late ... :(
yury is right are you still in problem
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.


and maybe the session timeout clean the session variable value?
ha, just guess, is it possible?
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!

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 :

If IsArray( sCartItemNums) then
nNumCartItems = ubound(sCartItemNums)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.