Ask a Question related to ASP, Design and Development.
-
Bob Cottis #1
IsNull bug in ASP?
I am getting wierd behaviour with IsNull in ASP. I am
passing a string (which may be null) to a function. When
the string is null, IsNull seems to return false the
first time it is called, then True the second time. The
code follows, am I doing something wrong, or is this a
bug?
Bob
function unquote(st) 'make database string suitable for
output
'#################
Dim test, test2
test = IsNull(st)
test2 = IsNull(st)
if test then
unquote=st
exit function
end if
response.write("In unquote st = " & st & "; isNull(st)
=" & IsNull(st) & "; " & test & "; " & test2 & "<br>")
'if st is null, test is false, but test2 is true
st = replace(st, "&", "&")
st = replace(st, "'", "'")
st = replace(st, """, chr(34))
st = replace(st, "<br>", chr(13) & chr(10))
unquote = st
end function
Bob Cottis Guest
-
Using IF and IsNull statements in SELECT
You would do something like this... select CustomerLastName + isnull(', '+CustomerFirstName,'') from tb -- -oj RAC v2.2 & QALite!... -
Evertjan. #2
Re: IsNull bug in ASP?
Bob Cottis wrote on 15 okt 2003 in
microsoft.public.inetserver.asp.general:There is no such thing as a "null string" in vbs.> I am
> passing a string (which may be null)
st = null is not a atring, so you cannot do replaces on it.
st = "" is an empty string, not a null, so:
isnull("") gives true
Perhaps you could, dependng on your application,
change the null variable to an empty string:
if isnull(st) then st = ""
?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Evertjan. Guest
-
WIlliam Morris #3
Re: IsNull bug in ASP?
A much safer method than relying on null values (which can cause havoc with
outputing a recordset, for instance):
If Len(Trim(MyPossiblyNullValue & " ")) = 0
'--- stuff here
End If
- Wm
--
William Morris
Product Development, Seritas LLC
"Bob Cottis" <anonymous@discussions.microsoft.com> wrote in message
news:2b13901c392e2$4557ec00$a601280a@phx.gbl...> I am getting wierd behaviour with IsNull in ASP. I am
> passing a string (which may be null) to a function. When
> the string is null, IsNull seems to return false the
> first time it is called, then True the second time. The
> code follows, am I doing something wrong, or is this a
> bug?
>
> Bob
>
> function unquote(st) 'make database string suitable for
> output
> '#################
> Dim test, test2
> test = IsNull(st)
> test2 = IsNull(st)
> if test then
> unquote=st
> exit function
> end if
> response.write("In unquote st = " & st & "; isNull(st)
> =" & IsNull(st) & "; " & test & "; " & test2 & "<br>")
> 'if st is null, test is false, but test2 is true
> st = replace(st, "&", "&")
> st = replace(st, "'", "'")
> st = replace(st, """, chr(34))
> st = replace(st, "<br>", chr(13) & chr(10))
> unquote = st
> end function
>
WIlliam Morris Guest



Reply With Quote

