Click to See Complete Forum and Search --> : ERROR: Operator '=' is not defined for type 'DBNull' ...


laxatcg1
January 23rd, 2007, 05:59 AM
Operator '=' is not defined for type 'DBNull' and string "Option".

I get this above mentioned error while running the application and the following is the code where I get this error.

If dr("Option") = "Option1" Then
...
...
...
End If

I know this happens when there is no record in the DB and has a value 'NULL". But I don't know how to handle this? Please guide me. Thank you!

jasonli
January 23rd, 2007, 08:13 AM
If dr("Option") isnot DBNull.Value andalso dr("Option") = "Option1" Then
.....

End If