orionbrock32
07-07-2006, 04:12 PM
Question.... If i am pulling a value from an access db that is type currency and trying to compare it to a number entered by the user could this cause a problem. Do i need to convert it to a number first?
|
Click to See Complete Forum and Search --> : Number v. Currency orionbrock32 07-07-2006, 04:12 PM Question.... If i am pulling a value from an access db that is type currency and trying to compare it to a number entered by the user could this cause a problem. Do i need to convert it to a number first? dthurman1432 07-07-2006, 04:34 PM To get this clear. For example you have in the access database a value of $1.00 and compare it someone entering in the number 1 instead of 1.00? And if so what is the error? Can you post you're query? orionbrock32 07-07-2006, 04:48 PM I am not getting an error, it just simply isn't working. If I put actual numbers in then the If statement works. but when I use the variables it acts as if it is true regardless of the number pulled from the db. set rstemp = oCmd.execute(checkSQL) 'Set recordset to SQL string above Do Until rstemp.eof dbRate =rstemp(23) If twenty > dbRate Then response.write("The entered number is bigger <br>") End If response.write(twenty & " is what was entered, compared to what is in the valid rate "& dbRate & "<br>") rstemp.movenext loop the page displays this when ran. The entered number is bigger 1900 is what was entered, compared to what is in the valid rate 2112 The entered number is bigger 1900 is what was entered, compared to what is in the valid rate 1866 Where 1900 is the number entered and 2112 and 1866 are the numbers from the db. russell 07-08-2006, 12:08 AM two samll pieces of advice: 1) always explicitly cast values unless you are 100% certain they are the same data type 2) never never never use currency or money data types. use decimal data types and set the precision and scale you want in the database. orionbrock32 07-10-2006, 09:38 AM Not to make excuse but I am working with what I have, the db was set up when I arrived at this company. So what I need to do then is convert the currency to a number before comparing? russell 07-12-2006, 11:01 AM yes. cdbl() for floating point numbers, clng() for integer values webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |