Solved

How do you evaluate for NULL in ADO

Posted on 2002-07-01
6
187 Views
Last Modified: 2010-04-01
I am trying to retrieve the value of a field that could be NULL.  I do this by using the following call:

strcpy(string, (LPCSTR)(_bstr_t)pFields->GetItem(vtIndex)->Value);

My database allows fields to be NULL.  Therefore, unless I want to keep receiving an exception error, I need to check the value for NULL.  Problem is, I'm not sure how to do that.  

Can someone help?!?
0
Comment
Question by:kingservant
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:Chizl
ID: 7123275
Looks like your doing a RecordSet loop.  I would suggest you try GetRows(-1) to get your data returned into a _variant_t array, then close your recordset.   Then your eval will be much simpler and your process time will be much faster.

I have an example of this up on:
http://www.chizl.com/dev/c++/

Let me know if you have any questions about it.
0
 
LVL 4

Expert Comment

by:Chizl
ID: 7123279
BTW.. About the NULL, try catch() is the solution, but still suggest using GetRows(-1).   The -1 is for all records.
0
 
LVL 4

Accepted Solution

by:
Chizl earned 350 total points
ID: 7123282
hehe.. Post again..  If you go the way I suggest you would use this:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q229088
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kingservant
ID: 7123463
Out of all the people who have responded to me on this forum, you have got to be the best!  Thanks for your response, complete with code examples and links, I love it.  I'll grade your answer tomorrow after I get to work.  BTW, do you have any other suggestions I could make to my code to make it more efficient?
0
 

Author Comment

by:kingservant
ID: 7124508
Thanks for you response.  You're the best!
0
 

Author Comment

by:kingservant
ID: 7124743
Thanks for you response.  You're the best!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question