Connecting Tech Pros Worldwide Forums | Help | Site Map

check if field is empty/nothing/null????

cj2
Guest
 
Posts: n/a
#1: Nov 21 '08
if myodbcreader.hasrows then
if myodbcreader("code").trim = "" or myodbcreader("reas").trim = "aVAL"
then
do something
endif
endif

Is this the appropriate way to test if the code field is something other
an a value? I find I can also say if myodbcreader("code").trim = nothing.

What about or vs orelse? I've heard I should use orelse yet I don't
know why.

zacks@construction-imaging.com
Guest
 
Posts: n/a
#2: Nov 21 '08

re: check if field is empty/nothing/null????


On Nov 21, 2:43*pm, cj2 <c...@nospam.nospamwrote:
Quote:
if myodbcreader.hasrows then
* * * * if myodbcreader("code").trim = "" or myodbcreader("reas").trim = "aVAL"
then
* * * * * * * * do something
* * * * endif
endif
>
Is this the appropriate way to test if the code field is something other
an a value? *I find I can also say if myodbcreader("code").trim = nothing.
>
What about or vs orelse? *I've heard I should use orelse yet I don't
know why.
Orelse means that if the first condition is true, then don't bother to
check the next condition.

Best way to check to see if a column in an ODBCDataReader is null is
to use the IsDBNull method.
cj2
Guest
 
Posts: n/a
#3: Nov 21 '08

re: check if field is empty/nothing/null????


isdbnull reports false when the field is = "" or " ". What I was
trying to say when I said "when a field is something other than a value"
was I don't consider "" or " " a value.


zacks@construction-imaging.com wrote:
Quote:
On Nov 21, 2:43 pm, cj2 <c...@nospam.nospamwrote:
Quote:
>if myodbcreader.hasrows then
> if myodbcreader("code").trim = "" or myodbcreader("reas").trim = "aVAL"
>then
> do something
> endif
>endif
>>
>Is this the appropriate way to test if the code field is something other
>an a value? I find I can also say if myodbcreader("code").trim = nothing.
>>
>What about or vs orelse? I've heard I should use orelse yet I don't
>know why.
>
Orelse means that if the first condition is true, then don't bother to
check the next condition.
>
Best way to check to see if a column in an ODBCDataReader is null is
to use the IsDBNull method.
Stephany Young
Guest
 
Posts: n/a
#4: Nov 21 '08

re: check if field is empty/nothing/null????


You've got a number of choices about how to deal with this issue.

The first thing to do is investigate the methods exposed by the
OdbcDataReader class.

The IsDBNull and GetString methods jump out immediately and used in
conjunction with the String.Trim and String.IsNullOrEmpty methods you should
be able to develop a very robust handler.


"cj2" <cj2@nospam.nospamwrote in message
news:OLTyiMCTJHA.1160@TK2MSFTNGP02.phx.gbl...
Quote:
isdbnull reports false when the field is = "" or " ". What I was trying
to say when I said "when a field is something other than a value" was I
don't consider "" or " " a value.
>
>
zacks@construction-imaging.com wrote:
Quote:
>On Nov 21, 2:43 pm, cj2 <c...@nospam.nospamwrote:
Quote:
>>if myodbcreader.hasrows then
>> if myodbcreader("code").trim = "" or myodbcreader("reas").trim =
>>"aVAL"
>>then
>> do something
>> endif
>>endif
>>>
>>Is this the appropriate way to test if the code field is something other
>>an a value? I find I can also say if myodbcreader("code").trim =
>>nothing.
>>>
>>What about or vs orelse? I've heard I should use orelse yet I don't
>>know why.
>>
>Orelse means that if the first condition is true, then don't bother to
>check the next condition.
>>
>Best way to check to see if a column in an ODBCDataReader is null is
>to use the IsDBNull method.
Closed Thread