Detecting empty or null value?

Discussion in 'ASP General' started by jodleren, Oct 27, 2009.

  1. jodleren

    jodleren Guest

    Hello all

    I tryid to find anything here, but not exactly what I need. My
    solution as of now is:

    sMine=rsjob.fields(0).value
    if sMine & ""="" then sMine="undefined"

    Just how should it be properly done?

    if smine="" or smine=NULL then ?
    The =null does not work :)

    What is the right thing then?

    WBR
    Sonnich
     
    jodleren, Oct 27, 2009
    #1
    1. Advertisements

  2. jodleren

    Bob Barrows Guest

    Nothing is wrong with that. Is it giving you the wrong answer?
    vbscript has two ways of testing for null:

    if sMine Is Null then

    or

    if IsNull(sMine) then

    Either works.
     
    Bob Barrows, Oct 27, 2009
    #2
    1. Advertisements

  3. jodleren

    rob^_^ Guest

    Hi,

    Just append a zero length string to convert nulls to zero length strings.
    sMine=rsjob.fields(0).value & ""

    for string fields. For numeric fields, make sure they do not allow nulls and
    that the default binding value is valid.

    This also works for asp query parameters and makes coding in asp.net easier.

    sValue = request("sValue") & ""

    I/O

    if not request("sValue") is nothing then
    .....etc.

    Regards.
     
    rob^_^, Dec 12, 2009
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.