Results 1 to 3 of 3

Thread: NULLS with ASP

  1. #1
    Join Date
    Dec 2003
    Posts
    148

    Angry Unanswered: NULLS with ASP

    Hi all. In process of moving ASP apps from SQL server to Oracle using DTS mainly.
    The app works fine with one exception, I have a conditional statement

    Code:
    if RS("Comment") = "" then
    Response.Write "<td class=smShadeLite>&nbsp;" & RS("prepared") & "</td>" 
    else
    Response.Write "<td class=smShadeLite>&nbsp;<A HREF='javascript:void(null)' ONCLICK='popup(""" &  Comment & """);'>" & RS("comment") &"</a></td>"
    end if
    The above code worked fine, in SQL Server. However, I am assuming because of the way oracle treats nulls this is not working. Please correct me if I am wrong, but do Oracle Null fields have to explicitly say "NULL"?
    I have tried messing around with what is in the quotes and such but to no avail. The Comment field is nullable in the Oracle DB and I just cannot get this to work. Any insight is appreciated.

  2. #2
    Join Date
    Mar 2004
    Location
    Warsaw / Poland
    Posts
    73
    I think this should work:
    Code:
    If RS("Comment").Value Is System.DBNull.Value Then
      Response.Write "<td class=smShadeLite>&nbsp;" & RS("prepared") & "</td>" 
    Else
      Response.Write "<td class=smShadeLite>&nbsp;<A HREF='javascript:void(null)' ONCLICK='popup(""" &  Comment & """);'>" & RS("comment") &"</a></td>"
    End If
    Of course, if you need your website working on both sql&oracle you need one more if...
    Code:
    If DB_Server = "Oracle" Then
      oracle stuff here
    Else
      sql server code
    End If
    Thanks,
    Grzegorz

  3. #3
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    Hi, you should never, even if using ASP only, treat nulls as empty strings.

    Try something like..
    Code:
    if LenB(RS("Comment")) = 0 then
    Response.Write "<td class=smShadeLite>&nbsp;" & RS("prepared") & "</td>" 
    else
    Response.Write "<td class=smShadeLite>&nbsp;<A HREF='javascript:void(null)' ONCLICK='popup(""" &  Comment & """);'>" & RS("comment") &"</a></td>"
    end if

Posting Permissions

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