1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

NULL Values, going nuts here

Discussion in 'C#' started by cacalano, Jun 30, 2008.

  1. #1
    Hi. I have a bit of code to look for any records with NULL. What I need is this. If the EOS_Date field is NULL, don't do the calculation. Check first if the 'EOS_Date'field is NULL, if so, Just display "eos" and exit the IF statement. Error trapping I'd say is what I'm doing here.

    When I test using a different field in the same table, I get the expected results, so my if structure is ok. So, it's something to with checking for NULLS. Syntax error possibly?

    thanks in advance. please help. tx.

    <% If TRIM(FP_FieldVal(fp_rs,"Codes")) = "UKRP" _
    OR TRIM(FP_FieldVal(fp_rs,"Codes")) = "EEP" _
    OR TRIM(FP_FieldVal(fp_rs,"Codes")) = "UK" Then %>

    <%Else%>


    <% If TRIM(FP_FieldVal(fp_rs,"EOS_Date")) = "" Then %>
    <td nowrap><font size="2" face="Arial">no eos date

    <%Else%>

    <td nowrap><font size="2" face="Arial"><%=FormatCurrency(FP_FieldVal(fp_rs,"Ref_Price")* FP_FieldVal(fp_rs,"EOS-Today") /FP_FieldVal(fp_rs,"EOS-HP_INTRO")) %></font></td>

    <%End If %>
    <%End If %>
     
    cacalano, Jun 30, 2008 IP
  2. cacalano

    cacalano Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ALso wanted to mention I get an error now because the IF statement doesn't capture the null, then send the NULL to the calculation. That's where is bombs. thanks again.
     
    cacalano, Jun 30, 2008 IP
  3. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #3
    try
    <% If TRIM(FP_FieldVal(fp_rs,"EOS_Date")) = "" or TRIM(FP_FieldVal(fp_rs,"EOS_Date")) = "null" Then %>

    write the exact error you get
     
    ludwig, Jun 30, 2008 IP
  4. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #4
    Post the error message. Also, a NULL is not going to equal a zero-length string. Have you tried using the VBScript IsNull(expression) function?
     
    Social.Network, Jun 30, 2008 IP
  5. helpbeam

    helpbeam Guest

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try

    Replace
    <% If TRIM(FP_FieldVal(fp_rs,"EOS_Date")) = "" Then %>
    With

    <% If Not IsNull(FP_FieldVal(fp_rs,"EOS_Date")) Then %>
     
    helpbeam, Jul 2, 2008 IP
  6. Forrest

    Forrest Peon

    Messages:
    500
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Do this in the database, by using the EOS_Date column in the calculation. Null is unknown ... it's the absence of any value. Null doesn't equal anything ( including null ) and when you use it in any calculation, the result is unknown / doesn't have a value. So, database engines return null when a null value is used in a calculation.

    Try it:

    Select null * 5
    Code (markup):
     
    Forrest, Jul 8, 2008 IP