Forum Moderators: open

Message Too Old, No Replies

trying to add numbers in a recordset

         

Andrew Thomas

3:55 pm on Oct 22, 2003 (gmt 0)

10+ Year Member



I have the following code

<% total=total+Clng(rs_orderlines("Value")) %>
<% Response.write(total)%>

which should add the field "value" and give a total.

but i get this error :

error '80020009'
Exception occurred.

value is type 'Number' in access database

thanks

Andrew

txbakers

4:20 pm on Oct 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



shouldn't that be "CINT" instead of "CING"?

wardbekker

7:08 pm on Oct 22, 2003 (gmt 0)

10+ Year Member



Clng is also valid, that's a convert to long int. Before executing this statement, check if the variable is a number with IsNumeric(var)

txbakers

9:26 pm on Oct 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hee hee - that was "LNG" then. It looked like "ING"

darn computer typefaces.

Andrew Thomas

9:37 am on Oct 23, 2003 (gmt 0)

10+ Year Member



Still get the same error, ive now changed the data type in the access database to currency, but it makes no difference.

any ideas

Andrew Thomas

9:54 am on Oct 23, 2003 (gmt 0)

10+ Year Member



found the problem: i put

<%total=total+(rs_orderlines.Fields.Item("Value").Value)%>

and it worked.

thanks

txbakers

10:34 pm on Oct 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah yes. Deceptive Javascript valuations of a variable.

I run into the same problem....sometimes. When you need an exact value of the variable you need to spell out the whole rsRecordSet.Fields.Item("").Value.

this crops ups with me mostly with strings where, like in Java, a static string doesn't necessarily "equal" the database variable. In java we would use the ".equals" method of the variable instead of the equality operator (==) to check for matches.

I don't know fully why you need to do this in ASP/JS but I do know to check that sometimes.