Solved

How do you evaluate for NULL in ADO

Posted on 2002-07-01
6
183 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now