Here's the problem: You're using PLUS signs to concatenate strings instead of AMPERSAND signs.
Code:
OrderData.Open("Select ProductID From Items where OrderID='" & OrdID & "'")
In VBScript, the ampersand is used for string concatenation. When you use a plus, it tries to "literally" add the parameters, resulting in a type mismatch (since you're adding a number to a string).
CStr() will bypass the error as you figured out (by making both arguments strings), but the correct way is to just use ampersands for string concatenation anywhere you are writing vbscript. (Jscript uses + just like java and c++).
Also, it'd probably be better to remove the single quotes from the SELECT statement as well, since OrderID is a numeric field. The single quotes means you pass SQL a string, which it then has to convert back to a number to compare it to the OrderID field. Every millisecond saved is a millisecond faster that your page loads!
I would write it like this:
Code:
OrderData.Open("Select ProductID From Items where OrderID=" & OrdID)
Last edited by nyef; 06-09-2008 at 07:30 PM..
|