|
|
 |
RE: FN-FORUM: Null testing problem
date posted 3rd January 2006 23:08
Craig wrote:
> Hi,
>
> I'm using the following code after doing a good bit of googling to
> find out how to test for NULL in datareader items in ASP.NET VB.
> However, when an item actually contains Null, it blows up. Any
> ideas?
>
> If DBRead.Item("Region") = "" OR DBRead.Item("Region")Is DBNull.Value
> Then .region = ""
> Else
> .region = DBRead.Item("Region")
> End If
>
> Regards,
>
> Craig
At a guess switch the test round as you are testing the value before you
check for null.
If ((DBRead.Item("Region")Is DBNull.Value) OR (DBRead.Item("Region") = ""))
Then
IIRC VB uses standard shortcircuiting of If so if first condition is true
second condition will not be tested and code won't "blow up".
Regards,
Dai
|
 |
|