Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

Show are if a parameter is not NULL

I have a stored procedure that updates a record.
I need to add code so that it only runs IF the parameter passed has a value

The parameter is:  request.querystring("marriageidspouse")

If the parameter does existing run the SP code, something like:

IF request.querystring("marriageidspouse") <> NULL THEN 

MY CODE

END IF

Open in new window


What would the correct syntax be?

Sometimes the part of the URL passes no value like:  marriageidspouse=

I am using classic ASP
Avatar of Big Monty
Big Monty
Flag of United States of America image

nulls are funky in ASP, most of the time they are just blank value. this should get you what you want:

request.querystring("marriageidspouse")
IF not isNull( marriageidspouse ) or marriageidspouse <> "" THEN 

MY CODE

END IF

Open in new window

Avatar of Aleks

ASKER

I tried this but did not work:

I tried the code above and the one below:

<% If Not isNull request("marriageidspouse")  or request("marriageidspouse") <> "" Then %>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aleks

ASKER

This seems to have worked:

<% If Not isNull (request("marriageidspouse"))  AND (request("marriageidspouse")) <> "" Then %>

Open in new window

just use empty string

IF request.querystring("marriageidspouse") <> "" THEN 

MY CODE

END IF

Open in new window

@HK

how is your answer in any ways different than what I already suggested? Please don't repeat answers, its unnecessary, especially after an answer has already been accepted.
when I posted it, it was not closed/accepted...
also, there is no mention of opening and closing tags anywhere...
+ 1st post is wrong and all post mentions using isNull...
when there is no such key exists or nothing is passed as value, it is converted to empty string...
Avatar of Aleks

ASKER

Ok now it's closed. Thx to both.