|
|
 |
RE: FN-FORUM: Null testing problem
date posted 3rd January 2006 23:19
Alternatively in your SQL use isnull(Region, '') to return '' if Region
is null at that point.=20
-----Original Message-----
From: [EMAIL REMOVED] [EMAIL REMOVED] On Behalf Of Dai
Williams
Sent: 03 January 2006 23:37
To: Andy Macnaughton-Jones
Subject: RE: FN-FORUM: Null testing problem
Craig wrote:
> Hi,
>=20
> I'm using the following code after doing a good bit of googling to=20
> 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? =20
>=20
> If DBRead.Item("Region") =3D "" OR DBRead.Item("Region")Is =
DBNull.Value
> Then .region =3D ""
> Else
> .region =3D DBRead.Item("Region")
> End If
>=20
> Regards,
>=20
> Craig
At a guess switch the test round as you are testing the value before you
check for null.=20
If ((DBRead.Item("Region")Is DBNull.Value) OR (DBRead.Item("Region") =3D
"")) 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
--
Freelancers, contractors earn more with Prosperity4 Call 0870 870 4414
or visit www.prosperity4.com and benefit from Inland Revenue approved
expenses today.
To advertise here: http://www.freelancers.net/advertising.html
|
 |
|