PDA

Click to See Complete Forum and Search --> : Checking for Null


venerable bede
Oct 15th, 2002, 07:36 AM
The following code :

If Not objROw2(0).Item("ClientLocality") Is Nothing Then
Me.lblLocality.Text = objROw2(0).Item("ClientLocality")
End If

Causes the following error when it contains nothing:

Additional information: Cast from type 'DBNull' to type 'String' is not valid.

Whats happening??

Thanks in Advance
:confused:

Tygur
Oct 15th, 2002, 02:40 PM
Try it this way instead:

If Not objROw2(0).Item("ClientLocality") Is DBNull.Value Then
Me.lblLocality.Text = objROw2(0).Item("ClientLocality")
End If

Basically, just change "Nothing" to "DBNull.Value".