[dba-VB] Checking for NULL and empty strings

David Emerson newsgrps at dalyn.co.nz
Thu May 24 19:20:54 CDT 2007


Group,

I am wanting to test the value of a field from a data source.  If it 
is NULL or "" then do one thing, otherwise do another.  Here is my vb.net code:

         If IsDBNull(Fields("MAddress2").Value) Or 
(Fields("MAddress2").Value = "") Then
             Me.txtMailAddress.DataField = "=MAddress1"
         Else
             Me.txtMailAddress.DataField = "=MAddress1" + Chr(34) + 
", " + Chr(34) + " + MAddress2"
         End If

The error message is "

Operator '=' is not defined for type 'DBNull' and string "".

What is the correct syntax for this?


Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand 


More information about the dba-VB mailing list