views:

38

answers:

3

Hi,

I am very new to asp and having following problem

I am getting 2 values from 2 column, from database and when i try to multiply them, its giving following error

Error Type:
(0x80020009)
Exception occurred.

This is my code

totalPrice = totalPrice + rs("ProductQunaity") * rs("ProductPrice")

Even if someone can tell me what should be "Title" of this question, that would be great.

A: 

Are you sure you typed that correctly?

                                              # (what's this?) ---v
totalPrice = totalPrice + rs("ProductQunaity") * rs("ProductPrice"`)
amphetamachine
Sorry for mistyping, corrected now.
itsaboutcode
+2  A: 

In case the error that amphetamachine pointed out is only in your code here at SO and not in the original code, please make sure that you don't have any type errors ( ;) ) with the values either.

totalPrice = totalPrice + CInt(rs("ProductQuantity")) * CDbl(rs("ProductPrice"))

where CInt() converts a value to an integer, and CDbl() converts a value to a double.

However, if you're very new to ASP, I'd recommend going straight to ASP.NET - ASP is a technology that hasn't developed in the last decade, while ASP.NET is Microsoft's new, fully supported (and pretty awesome) web development platform.

I'd recommend you start with ASP.NET MVC, since it is usually a lot cleaner, and it's straightforward to output the html you want. This and this are two good places to start.

Tomas Lycken
Thanks Tomans, it was really helpful answer and solved my problem. Problem is its kind of class assignment. So have no choice but to work with this old technology. Thanks again.
itsaboutcode
@itsaboutcode, If this is a school assignment, you really should have tagged it [Homework]. The StackOverflow community is generally really eager to help, but the best way to help you with schoolwork is usually not to give you the answers straight away. That said, you should give your teacher a hint that he's teaching dinosaur technology ;)
Tomas Lycken
A: 

Whenever you have errors like this, the best way to debug them is to response.write all the values out, then response.end before the line throwing the error is run. You can then inspect the values and attempt to work out why they are not compatible.

Tom Gullen