Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    40

    Unanswered: If statement Not Working

    After a recent switch from MS Access to SQL Server 2000 some simple ASP if statements seem to not work.

    In MS Assess I would use this an if statement to determine if a field was null.

    <% if objRS("Review") <> "" then %>

    Now this doesn't work to evelauate the field in SQL Server 2000 for null. I work with allot of text and it seems redundant for me to put triggers into the databases that will have to be maintained and updated when a text fields is empty or not.

    Anyone with experience in this or who knows how to work with if statements, ASP when dealing with SQL Server 2000 would be greatly appreciated.

    Thanks,

    JimWa

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    In MSSQL, you need to use

    <% if Not IsNull(objRS("Review")) then %>

  3. #3
    Join Date
    Jan 2004
    Posts
    40
    Thats seems to have done the trick. Thank you so much for your help!

    You wouldn't happen to know why working with Double quotes " is an issue with SQL Server do you?

  4. #4
    Join Date
    Dec 2003
    Posts
    454
    <% if objRS("Review") <> "" then %> is used to check if the field is blank.

  5. #5
    Join Date
    Jan 2004
    Posts
    40
    Yes that works in MS Access as the backend... And what I use currently. Am testing my new database (MS Sequel Server 2000) and it does not work.

    And I tested the wrong thing early. Your example didn't work as I had previoulsy thought it did.

    It's like it can't recongnize blank text fields or something.

  6. #6
    Join Date
    Dec 2003
    Posts
    454
    If you think that the value of the field may be NULL or empty, it is better to use the following statement:

    <%
    If Not IsNull(RS("columnName")) And Not IsEmpty(RS("columnName")) Then
    %>

Posting Permissions

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