Ask a Question related to ASP, Design and Development.

  1. #1

    Default 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, "&#38;", "&")
    st = replace(st, "&#39;", "'")
    st = replace(st, "&#34;", chr(34))
    st = replace(st, "<br>", chr(13) & chr(10))
    unquote = st
    end function

    Bob Cottis Guest

  2. Similar Questions and Discussions

    1. Using IF and IsNull statements in SELECT
      You would do something like this... select CustomerLastName + isnull(', '+CustomerFirstName,'') from tb -- -oj RAC v2.2 & QALite!...
  3. #2

    Default Re: IsNull bug in ASP?

    Bob Cottis wrote on 15 okt 2003 in
    microsoft.public.inetserver.asp.general:
    > I am
    > passing a string (which may be null)
    There is no such thing as a "null string" in vbs.

    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

  4. #3

    Default 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, "&#38;", "&")
    > st = replace(st, "&#39;", "'")
    > st = replace(st, "&#34;", chr(34))
    > st = replace(st, "<br>", chr(13) & chr(10))
    > unquote = st
    > end function
    >

    WIlliam Morris Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139