Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

Type mismatch: 'iProductID' poss prob with array

On my orderConfirmation Page I do this:
strItemID=Request.Form ("txt_itemID")   where txt_itemID is the hidden text field on the CustomerDetails page holding the ID of the product they have chosen.
Again here I use a Select Statement to select the details of the chosen product from my database like this:
dim arrProducts(3,3)
dim i
i=0
SQLQuerymake= "SELECT * FROM tbl_photography where picID= " & strItemID & ""
set rs_pics=objconn.execute(SQLQuerymake)

WHILE NOT rs_pics.EOF
      arrProducts(i,1)= rs_pics("picID")      
      arrProducts(i,2)= rs_pics("price_a3")
 arrProducts(i,3)= rs_pics("small_photo")      
      i = i + 1
  rs_pics.movenext
WEND
But on  the orderConfirmation Page I am getting the error message:
Type mismatch: 'iProductID'
/orderConfirmation_TUE.asp, line 83
Where line 83 is:
sngTotal=sngTotal + (cint(iQuantity) * csng(arrProducts(iProductID,2)))

Can you explain why?

0
rabbits2
Asked:
rabbits2
  • 5
  • 3
  • 2
  • +2
2 Solutions
 
GawaiCommented:
change to
SQLQuerymake= "SELECT * FROM tbl_photography where picID= '" & strItemID & "'"
0
 
GawaiCommented:
if txt_itemID data type is text or not an integer then my above code should work.
you should wrap the text with '
0
 
Mass Dot NetCommented:
Let's dig a bit deeper.  Add some debugging code on your order confirmation page, like so:

=====================================================
Call Response.Write("iQuantity = " & iQuantity & "<br>" & vbNewLine)
Call Response.Write("iProductID = " & iProductID & "<br>" & vbNewLine)
Call Response.Write("arrProducts(" & iProductID & ",2) = " & arrProducts(iProductID,2) & "<br>" & vbNewLine)
Call Response.Write("cSng(arrProducts(" & iProductID & ",2)) = " & CSng(arrProducts(iProductID,2)) & "<br>" & vbNewLine)

sngTotal=sngTotal + (cint(iQuantity) * csng(arrProducts(iProductID,2)))
=====================================================


Which line does the error occur on now?  My guess is that you're looking in the wrong place in the arrProducts array.  But without being able to see the order confirmation page's code, I can't be sure.


-= DeathToSpam =-
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
rabbits2Author Commented:
txt_itemID data type is an Atomated number.
I will try with the debugging now, thanks.
0
 
golfDoctorCommented:
In the code you posted, you never assign a value to iProductID, but you use it as integer.  That would cause error.
0
 
rabbits2Author Commented:
After debugging I get this response:
iQuantity =
iProductID =
arrProducts(,2) = 180
cSng(arrProducts(,2)) = 180

Microsoft VBScript runtime error '800a000d'
Type mismatch: ''
/orderConfirmation_TUE.asp, line 91
Where line 91 is the same line where the error occured before:
sngTotal=sngTotal + (cint(iQuantity) * csng(arrProducts(iProductID,2)))

So I am missing some required data, no?
0
 
rabbits2Author Commented:
180 is the individual item price, but I had selected 2
0
 
golfDoctorCommented:
Like I said, "you never assign a value to iProductID, but you use it as integer.  That would cause error."
0
 
Mass Dot NetCommented:
Rabbits2 --

You'll notice that the value of [iProductID] is blank.  Because you're using [iProductID] to try and figure out which row in the [arrProducts] array you want to get the price from, that's causing any error -- it should be displaying an integer, at the very least.

You'll need to post more of your confirmation page's code -- I really can't say what else might be going wrong, without seeing it.


-= DTS =-
0
 
rabbits2Author Commented:
I will try and sort my code so as not to post too much.  This may take me a while, please check back tomorrow. Thanks for yr help so far.
The problem is I am passing a cart over three pages and this is the first time I have done this, I can't possibly post three pages of script for you to paw through so will try and organise the specifics of what I need to achieve. thanks
0
 
golfDoctorCommented:
put all the values in session variables, add new in each page, rather than passing through pages.
0
 
rabbits2Author Commented:
ok will give it a go. Thanks
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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