Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old November 21st, 2008, 07:55 PM
cj2
Guest
 
Posts: n/a
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.
  #2  
Old November 21st, 2008, 08:45 PM
zacks@construction-imaging.com
Guest
 
Posts: n/a

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.
  #3  
Old November 21st, 2008, 09:55 PM
cj2
Guest
 
Posts: n/a

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.
  #4  
Old November 21st, 2008, 10:45 PM
Stephany Young
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
try Catch for empty textfield John Devlon answers 9 August 31st, 2006 11:55 PM
Conditionally write a Template Item is data in field exists? D. Shane Fowlkes answers 2 November 18th, 2005 10:20 AM
need to check if field is empty Krechting answers 5 November 13th, 2005 06:30 AM
how to populate empty field Alistair answers 8 July 19th, 2005 11:02 AM