Solved

How do you evaluate for NULL in ADO

Posted on 2002-07-01
6
185 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

809 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