CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001
    Posts
    22

    Check Null Value

    I do the following code:

    _varian_t vValue;
    long l;
    vValue=pRecordset->Fields->GetItem(_variant_t(0L))->Value;
    l=atol((char *)(_bstr_t)vValue);

    but when I reach to a record have NULL value in this field, this code will cause an error.
    So any body tell me how can I check the vValue was NULL before I call atol function.
    Thanks so much.

    Khinlau



  2. #2
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    97

    Re: Check Null Value

    You can simply go
    if(pRecordset->Fields->GetItem(_variant_t(0L))->Value!=NULL)
    {vValue=pRecordset->Fields->GetItem(_variant_t(0L))->Value;
    }


  3. #3
    Join Date
    Sep 2001
    Posts
    22

    Re: Check Null Value

    are you sure that code run well?
    I can not compile the code if(pRecordset... !=NULL)
    and you note that this recordset I use ADO.
    Thanks so much for you help
    Khinlau


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured