MarkItZero
Active member
Hello,
In my program I am reading several DB fields into text boxes on my form.
Ex
This works great, until there is a record with a null value in one of the fields. And the I get an error....
"Cast from type DBNull to type String is not valid"
Is there a way I can check to see if the field is NULL before reading it in.
I tried...
But that didnt seem to work.
Any Suggestions?
Thanks!
In my program I am reading several DB fields into text boxes on my form.
Ex
Code:
txtUserName.Text = Cstr(RcrdSt("UserName").Value)
txtIDNum.Text = CDbl(RcrdSt("IDNum").Value)
txtRate.Text = CDbl(RcrdSt("Rate").Value)
txtLocation.Text = CStr(RcrdSt("Location").Value
This works great, until there is a record with a null value in one of the fields. And the I get an error....
"Cast from type DBNull to type String is not valid"
Is there a way I can check to see if the field is NULL before reading it in.
I tried...
Code:
txtLocation.Text = IIF(IsDBNull(Cstr(RcrdSt("Location"))," ",Cstr(RcrdSt("Location"))
But that didnt seem to work.
Any Suggestions?
Thanks!