|
 |
asp_databases thread: Validation check for an integer value....
Message #1 by "Kalwinder" <k965408@k...> on Wed, 21 Mar 2001 19:16:42
|
|
In my database I have the quantity of stock defined as an integer and
likewise as long in my business object code.
Now when i enter a string instead of an integer i get an error and the
page crashes.
Is there any validation check I can perform (from within ASP) that will
display an helpul error messagge instead if i enter a string value instead
of a long value?????????
For example, for making sure I dont exceed the character lenght limit I do:
If (Len(request("qty")) > 5 then
response.write "not allowed"
else
response.write "is allowed"
end if
Your urgent help will be most appreciated..........Thank You
Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 21 Mar 2001 20:35:52 +0100
|
|
Hi there,
You can use the IsNumeric check to see if it is a number.
if IsNumeric(qty) then
else
end if
Also, you may want to make sure you have a integer number, by converting it
with CInt(qty) to an Integer, if the IsNumeric check returned true.
Take care of some rounding issues when using ASP. Checkout
http://msdn.microsoft.com/scripting/vbscript/doc/vbstoc.htm
for the documentation on VBScript used in ASP. I think you want to take a
look at the "Functions" section, to check out Cint and other conversion
functions.
Hope this helps,
Imar
At 07:16 PM 3/21/2001 +0000, you wrote:
>In my database I have the quantity of stock defined as an integer and
>likewise as long in my business object code.
>
>Now when i enter a string instead of an integer i get an error and the
>page crashes.
>
>Is there any validation check I can perform (from within ASP) that will
>display an helpul error messagge instead if i enter a string value instead
>of a long value?????????
>
>For example, for making sure I dont exceed the character lenght limit I do:
>
> If (Len(request("qty")) > 5 then
>
> response.write "not allowed"
> else
>
> response.write "is allowed"
> end if
>
>
>Your urgent help will be most appreciated..........Thank You
Message #3 by =?iso-8859-1?q?Bhanu=20Shanker=20Menon?= <bhanu271978@y...> on Thu, 22 Mar 2001 00:01:07 -0800 (PST)
|
|
HI Kalwinder,
You can use TypeName(expression) which would return
"Vbstring" if it is a string..
Hope this helps.
BHANU
--- Kalwinder <k965408@k...> wrote: > In my
database I have the quantity of stock defined
> as an integer and
> likewise as long in my business object code.
>
> Now when i enter a string instead of an integer i
> get an error and the
> page crashes.
>
> Is there any validation check I can perform (from
> within ASP) that will
> display an helpul error messagge instead if i enter
> a string value instead
> of a long value?????????
>
> For example, for making sure I dont exceed the
> character lenght limit I do:
>
> If (Len(request("qty")) > 5 then
>
> response.write "not allowed"
> else
>
> response.write "is allowed"
> end if
>
>
> Your urgent help will be most
> appreciated..........Thank You
>
|
|
 |