Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem reading information from Query

Status
Not open for further replies.

checco

Technical User
Aug 19, 2004
5
0
0
IT
Hello to All,
I'm occurring in one problem when I start to collect information from a query when the wanted filed it's empty.

Here after a part of my fault code:
...
AnsiString stringa;
...
stringa+=QAll->FieldValues["cdPartySubscriber"];
stringa+=",";
...
In this case if the field "cdPartySubscriber" is empty I receive the error "...my project raise an excepption class EVarianError with message "Invalid variant Type conversion".....

I want to do something like this:
...
if(QAll->FieldValues["cdPArtySubscriber"]!=NULL)
stringa+=QAll->FieldValues["cdPartySubscriber"];
stringa+=",";
...
but in this case the if is always ignored (the expression results always true) and I receive the same error message.

Just for infomation the db is oracle.

Some one can help me ?


Thanks in advance for any answer
Checco
 
I'm doing this from memory but it should point you to the right spot.
Code:
AnsiString stringa;
...
try
{
    stringa+=QAll->FieldValues["cdPartySubscriber"];
}
catch (&EVarianError)
{
    // Do something or nothing
}
stringa+=",";

What I don't remember is the exact format of the catch for this type of exceptions.

James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
Hi 2ffat,
first of all thanks for your help that is always very usefull.
With your suggestion I'm able to manage both case, but each time that I occour in the exception I receive the error message box.
Is it possible to "hide" that message in order to let my program continue ?

P.S. I've used this format for catch the exception:
catch (Exception &EVarianError)
May-be it is not correct ?

Thanks again for your usefull help,
Checco
 
Hi again to all,
please do not take care about my last reply... I'll take a crab ;-)))))

Sorry but I'm not so skilled.

2ffat Thank again you suggestion solve my problem in the best way.

Bye,
Checco
 
Your "if" statement may be failing because a field can be empty without being "NULL".
You need to also check for an empty string ("").
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top