Solved

vc++ ado NULL

Posted on 2002-04-29
26
424 Views
Last Modified: 2010-04-02
I have worked in  VB 6.0 ADO ,there i found a method ISNULL to check a field item is null or not.
I am currently in VC++ 6.0 Ado, i am not able to find such a method . How could i test a field is
null.
0
Comment
Question by:v_iyengar
  • 13
  • 6
  • 4
  • +2
26 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6976884
if (ptr == NULL)
{
}
0
 

Author Comment

by:v_iyengar
ID: 6976895
i want to check if Fields->GetItem(0l)->Value is null
0
 
LVL 30

Expert Comment

by:Axter
ID: 6976899
if (Fields->GetItem(0l)->Value == NULL)
{
}
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 30

Expert Comment

by:Axter
ID: 6976900
If you want to check if the return value of GetItem is null then you can do the following:
if (Fields->GetItem(0l)== NULL)
{
}
0
 
LVL 30

Expert Comment

by:Axter
ID: 6976903
If Value is a non-pointer, then I think what you're looking for is something like this.

if (Fields->GetItem(0l)== NULL)
{
  MyValue = Fields->GetItem(0l)->Value;
}
0
 
LVL 30

Expert Comment

by:Axter
ID: 6976905
Oops!  Correction:
if (Fields->GetItem(0l) != NULL)
{
 MyValue = Fields->GetItem(0l)->Value;
}
0
 

Author Comment

by:v_iyengar
ID: 6976948
i want to check with database null
0
 
LVL 30

Expert Comment

by:Axter
ID: 6976956
>>i want to check with database null
What do you mean?

What ever you have as a pointer, should be checked to see if the value equals to NULL.
0
 

Author Comment

by:v_iyengar
ID: 6976964
the value for an item in database can be NULL.
How can i check its null
Fields->GetItem(0l)->Value is a VARIANT ,how can i compare a VARIANT and NULL
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6976968
I think in the case of a NULLable charater field the variant type returned will be of type VT_NULL if the field is NULL.
0
 

Author Comment

by:v_iyengar
ID: 6976969
the value for an item in database can be NULL.
How can i check its null
Fields->GetItem(0l)->Value is a VARIANT ,how can i compare a VARIANT and NULL
0
 

Author Comment

by:v_iyengar
ID: 6976975
the value for an item in database can be NULL.
How can i check its null
Fields->GetItem(0l)->Value is a VARIANT ,how can i compare a VARIANT and NULL
0
 

Author Comment

by:v_iyengar
ID: 6976981
the value for an item in database can be NULL.
How can i check its null
Fields->GetItem(0l)->Value is a VARIANT ,how can i compare a VARIANT and NULL
0
 

Author Comment

by:v_iyengar
ID: 6976987
yes vt type is set to VT_NULL
But will all database will do the same,set VT to VT_NULL or i have to check some other code like scode
0
 

Author Comment

by:v_iyengar
ID: 6976997
yes vt type is set to VT_NULL
But will all database will do the same,set VT to VT_NULL or i have to check some other code like scode
0
 

Author Comment

by:v_iyengar
ID: 6977029
yes vt type is set to VT_NULL
But will all database will do the same,set VT to VT_NULL or i have to check some other code like scode
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6977092
Sorry but after lots of ploughing through documentation I can't find anything which gives me confidence that comparing against VT_NULL will be reliable in all weather. But I'm guessing it will probably be as reliable as your original VB test was.
0
 

Author Comment

by:v_iyengar
ID: 6977363
yes vt type is set to VT_NULL
But will all database will do the same,set VT to VT_NULL or i have to check some other code like scode
0
 

Author Comment

by:v_iyengar
ID: 6977374
so you mean ISNULL in vb only test for VT=VT_NULL
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6978558
As VB uses a variant type internally that is my suspicion.
0
 

Author Comment

by:v_iyengar
ID: 6979518
so u mean to say its enough if i check VT=VT_NULL ?
0
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 25 total points
ID: 6979759
No ....
I mean that's what "I" would do x.vt == VT_NULL,
but I would do it without great confidence because the
documentation is really crappy.
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7036271
Please update and finalize this old, open question. Please:

1) Award points ... if you need Moderator assistance to split points, comment here with details please or advise us in Community Support with a zero point question and this question link.
2) Ask us to delete it if it has no value to you or others
3) Ask for a refund so that we can move it to our PAQ at zero points if it did not help you but may help others.

EXPERT INPUT WITH CLOSING RECOMMENDATIONS IS APPRECIATED IF ASKER DOES NOT RESPOND.

Thanks,

** Mindphaser - Community Support Moderator **

P.S.  Click your Member Profile, choose View Question History to go through all your open and locked questions to update them.
0
 

Author Comment

by:v_iyengar
ID: 7040973
i am also doing the same,but i do not know is it correct?
0
 
LVL 11

Expert Comment

by:griessh
ID: 7122187
I suggest to split between Axter and GGRUNDY

======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7138107
Force accepted

** Mindphaser - Community Support Moderator **

Axter, there will be a separate question with points for your help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TTimer no longer functioning 7 90
returning a dereferenced pts in C++ 10 149
C++ assignment question 7 194
Should CArray be used for a list of pointers in C++? 19 102
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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

816 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

8 Experts available now in Live!

Get 1:1 Help Now