Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
September 15, 2004, 9:13 pm
rate this thread
Writing an ASP page and the following is never evaluating as true:
if request("Branch") = rsSet("BranchKey") then response.Write " selected
Branch is a SELECT value passed from a previous form submission.
BranchKey is a number stored in an MS Access database.
I'm assuming that the problem is that Branch returns a string (even though
it holds a number) and that rsSet("BranchKey") is returning a number and not
I've verified that both are returning similar values (ie Branch is "12" and
BranchKey is 12).
How can I make this comparison work? (or what group should I ask in - didn't
see anything ASP related)
Re: Compare number from DB to a form string in ASP
you are correct... all form items, even if its a number, come in as a string
First you want to check if request("branch") is numeric (just to be safe,
else you'll get a 500 asp error)
Then, if it is numeric you want to convert it to a number...
IF ISNUMERIC(request("branch")) THEN
if CINT(request("Branch")) = rsSet("BranchKey") then response.Write "
ISNUMERIC() is a boolean function... it will return "true" if the item in
brackets is numeric... and "false" if it is not.
CINT() is a function that will convert a string or other number to an
integer. If it cannot convert the string it will return an error (I say "or
other number" because 12345 is an integer... 12345.678 is NOT an integer
because it has a decimal point with value other than 0 after it...
CINT(12345.678) would return 12345)