| View previous topic :: View next topic |
| Author |
Message |
sam Guest
|
Posted: Tue Feb 13, 2007 6:56 pm Post subject: Null Values SQL2005 New to builder |
|
|
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 |
|
| Back to top |
|
 |
Clayton Arends Guest
|
Posted: Wed Feb 14, 2007 5:59 am Post subject: 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 |
|
| Back to top |
|
 |
Clayton Arends Guest
|
Posted: Wed Feb 14, 2007 9:10 am Post subject: 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 |
|
| Back to top |
|
 |
sam Guest
|
Posted: Wed Feb 14, 2007 9:10 am Post subject: 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" <nospam_claytonarends (AT) hotmail (DOT) com> wrote in message
news:45d250e9$1 (AT) newsgroups (DOT) borland.com...
| 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
|
|
|
| Back to top |
|
 |
|