Board index » cppbuilder » Null Values SQL2005 New to builder

Null Values SQL2005 New to builder


2007-02-13 08:56:10 PM
cppbuilder84
What is the best way to handle nulls with BCB6 with MSSQL 2005.
Every time the code hits a null it throws a exception or crashes the
program.
TIA
Sam
 
 

Re:Null Values SQL2005 New to builder

Can you give an example of where the program crashes? The exceptions I have
seen usually happen when attempting to convert a null Variant to string. Do
you have other crashes happening to you?
- Clayton
 

Re:Null Values SQL2005 New to builder

Same problem
I am new to user of builder 6
What is the best way to handle this?
TIA
Sam
"Clayton Arends" < XXXX@XXXXX.COM >wrote in message
Quote
Can you give an example of where the program crashes? The exceptions I
have seen usually happen when attempting to convert a null Variant to
string. Do you have other crashes happening to you?

- Clayton

 

{smallsort}

Re:Null Values SQL2005 New to builder

It depends on what you want to do with null data. If you want to treat
nulls as some value you can use VarToStr() or VarToStrDef(). Look them up
in the help for more info.
If you want to handle nulls differently then you can do something like this
whenever evaluating the field's value:
String strValue;
if (field->Value.IsNull())
// do some condition
else
strValue = field->Value; // or field->AsString;
Check out the help for TField and Variant for more info.
If you have a specific code example or a specific design question post it
and I'll try my best to help.
- Clayton