Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do you evaluate for NULL in ADO

Posted on 2002-07-01
6
Medium Priority
?
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1400 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
Technology Partners: 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

636 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