Defining a Number v Text

Graeme
Graeme used Ask the Experts™
on
Hello all and thanks in advance for your assistance

I am having issues with what I thought was how to tell the difference between a number and text by using IsNumeric, however I am finding that for example
If IsNumeric(Request.QueryString("all") Then

Open in new window

is processing and giving an output...

Is there something I am missing?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If IsNumeric(Request.QueryString("all") ) Then

Open in new window


Miss )
Graemewebber4technologies

Author

Commented:
Sorry Manuel, yes I did miss it in this Question... however it is in the code.. sorry again
The IsNumeric function returns a Boolean value that indicates whether a specified expression can be evaluated as a number. It returns True if the expression is recognized as a number; otherwise, it returns False.

<%

Dim x
x=10
response.write(IsNumeric(x) & "<br />")
x=Empty
response.write(IsNumeric(x) & "<br />")
x=Null
response.write(IsNumeric(x) & "<br />")
x="10"
response.write(IsNumeric(x) & "<br />")
x="911 Help"
response.write(IsNumeric(x))

%>
The output of the code above will be:

True
True
False
True
False
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Graemewebber4technologies

Author

Commented:
Thanks for that Manuel

The issue im getting is...

x="all"
response.write(IsNumeric(x))

If IsNumeric(x) Then

This is coming true and then proceeding in the IF statement
Graemewebber4technologies

Author

Commented:
The actual Code that is having an issue is:

Request.QueryString("event")="all"

If IsNumeric(Request.QueryString("event")) Then

Open in new window

Ryan ChongSoftware Team Lead

Commented:
x="all"
response.write(IsNumeric(x))
this returned as false to me.
Graemewebber4technologies

Author

Commented:
Hi Ryan, in post 42071145, I am displaying the code that is having an issue... :(

I have just thought of something... Its showing up on a page that doesnt require is... eg http://dev.gptouring.com.au/?
Ryan ChongSoftware Team Lead

Commented:
Request.QueryString("event")="all"
this should be an invalid statement and your page would have generated an error on screen.
Ryan ChongSoftware Team Lead

Commented:
Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression 'event_code=code_short AND event_start>Now() AND code_live=TRUE AND event_live=TRUE AND event_ID='. 

Open in new window


as what i guess... from this error, it mentioned that Request.QueryString("event") is missing which causing error in your SQL statement.

so you need to have a better error handling in case Request.QueryString("event") is not found.
Graemewebber4technologies

Author

Commented:
I think I have figured it out...

If IsNumeric(Request.QueryString("event")) AND NOT (Request.QueryString="" OR Request.QueryString="?") Then

Open in new window


doesnt error... is that because it would see "" OR "?" as IsNumeric?
Ryan ChongSoftware Team Lead

Commented:
If IsNumeric(Request.QueryString("event")) AND NOT (Request.QueryString="" OR Request.QueryString="?") Then
nope... what if you have this?

http://dev.gptouring.com.au/?x
http://dev.gptouring.com.au/?bla=

Open in new window

etc?
Graemewebber4technologies

Author

Commented:
I am getting errors on:
http://dev.gptouring.com.au/?category=70
Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression 'event_code=code_short AND event_start>Now() AND code_live=TRUE AND event_live=TRUE AND event_ID='.

Open in new window


Why would this happen?

Im not even asking for Request.QueryString("event") on this page...
Ryan ChongSoftware Team Lead

Commented:
Im not even asking for Request.QueryString("event") on this page... 

Open in new window

try post and examine the codes around:

AND event_ID=

Open in new window


and you should fine that something is missing there
webber4technologies
Commented:
I am now using:
If IsNumeric(Request.QueryString("event")) AND Len(Request.QueryString("event"))>0 AND NOT (Request.QueryString="" OR Request.QueryString="?") Then

Open in new window


Surely it shouldnt be that hard? should it?

for:
AND event_ID=

Open in new window

This isnt even on the IF statement page that it is writing, its complete different section...
Ryan ChongSoftware Team Lead
Commented:
i would simply use:

If IsNumeric(Request.QueryString("event")) Then

Open in new window


to ensure a numeric event (ID) was provided

This isnt even on the IF statement page that it is writing, its complete different section...
I think somehow in your codes logic, it hits that line of code and run it, which causing the error and display on your page.
Graemewebber4technologies

Author

Commented:
Yeah I a not sure why...

The homepage of the website is first in the hierarchy order and the Query that it is erroring on (the line we have seen
'event=') is after it.

just strange!

seems to be not erroring now, been through alot of pages and all good
Graemewebber4technologies

Author

Commented:
Strange that it is doing this, but work around works

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial