Link to home
Start Free TrialLog in
Avatar of Anthony Matovu
Anthony MatovuFlag for Uganda

asked on

dealing with null value.

Does vb.net have a direct function that deals with nulls, When i am loading values from a database to a form, when one field is null, i get the error massage can't convert dbnull to string, I dont want to do test "if if not isnull("field") then form control = field value". for example access had a function (NZ) that could automatically convert nulls to empty strings or 0.

ANTHONY MATOVU
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slado2
slado2

You may always compare the value of a field with DbNull.Value:
if dr("Field") = DBNull.Value then
   do something
end if

sorry for the syntax, I'm not a VB guy. DBNull.Value is defined in .NET.
Copied from Anthony's question....

"I dont want to do test "if if not isnull("field") then form control = field value""