Click to See Complete Forum and Search --> : Comparing Two Values


xesojay
10-06-2005, 10:37 AM
Hi Guys,
Am trying to compare two value using asp. The first value is what the user enter in a textbox and the second value will be what my recordset return from the db. But I got this error msg after I executemy code below. If you know a better way of doing this please let me know. Thanks

Error Msg : Error Type:
(0x80020009)
Exception occurred.
/mtn/fund_trans_req_act.asp, line 29


My code is this :

<!--#include file="Connections/Conn.asp" -->
<%
strUser=Session("MM_Username")

dim ObjConn, ObRs,strSql,strUser,RsSelect1,RsSelect2,strAccName,strBank
dim strAccNum,strAmount, strRef,strComment, strAuth1, strAuth2,strStatus,strIP

strAccName = request.Form("accname")
strBank = request.Form("bank")
strAccNum = request.Form("accnumber")
strAmount = request.Form("amount")
strRef = request.Form("mtn_ref")
strComment = request.Form("mtn_comment")
strAuth1 = request.Form("firstAuth")
strAuth2 = request.Form("SecondAuth")
strStatus = "1"
strIP = request.Form("Req_sys_IP")

set ObjConn = Server.CreateObject("adodb.Connection")
set ObjRs = Server.CreateObject("adodb.Recordset")
'set RsSelect1 = Server.CreateObject("adodb.Recordset")
'set RsSelect2 = Server.CreateObject("adodb.Recordset")

ObjConn.open("mtn")

strSql= " Select * from tblAuth where StaffID='"&strAuth1&"' "
set ObjRs = ObjConn.execute(strSql)
if CCur(request.Form("amount")) > CCur(ObjRs.fields("MaxAmount")) then
response.Write("<script>history.go(1); alert('Sorry !, Your First Authoriser can not Authorized this Transaction.\n As the amount is greater than what he can authorised.\n Please choose another Authoriser ')</script>")
end if
%>

russell_g_1
10-06-2005, 02:02 PM
probably because one of the values cannot be converted to currency type. one way to do this would be to write a simple function like this to handle errors.

function cCur2(x)

cCur2 = ccur(0)

if isnumeric(x) then
cCur2 = ccur(x)
end if

end function

doing this would mean you could get away with this lot

response.write cCur2(234) & "<br>"
response.write cCur2("") & "<br>"
response.write cCur2(nothing) & "<br>"
response.write cCur2(2.34) & "<br>"

xesojay
10-07-2005, 02:47 AM
hi,
Thanks for your reply. Please note that all are numeric and this has been handle from the front end using a validation script to ensure that they input numeric value. I have used the script you supply but still am receiving same error.
Futher aid will be appreciated.
Thanks.

sirpelidor
10-07-2005, 12:59 PM
hi, just like to give a shot here, hope this would help:

1) "MaxAmount" in ur sql table, is it integer? decmal? char? string?
2) i don't think there's anything wrong in request.Form("amount") being not numeric since u said u have front end checked (using regular expression)
3) try to convert MaxAmount to local variable by Dim it first. do whatever it can to make sure MaxAmount and request.Form("amount") are the same type.

hope this will shine some lights on ur problem :)