B
Bob Day
Why does below fail? I understand how to re-write the code to avoid the
failure, but it should not fail to begin with. Cannot DBNull be passed as
an object?
' holds extension number or DBNull if non exist
Dim Extension As String = Nothing
' get extension number or DBNull if non exist
Extension = Me.NullStringCheck(DataRow.fld_Extension_Digits)
' FAILS on line above when value is DBNull, error "cast from type DBNull to
type STRING is not valid"
Public Function NullStringCheck(ByVal Value As Object) As String
Select Case IsDBNull(Value)
Case True
Return ""
Case False
Return CStr(Value)
End Select
End Function
Please advise
Bob Day
failure, but it should not fail to begin with. Cannot DBNull be passed as
an object?
' holds extension number or DBNull if non exist
Dim Extension As String = Nothing
' get extension number or DBNull if non exist
Extension = Me.NullStringCheck(DataRow.fld_Extension_Digits)
' FAILS on line above when value is DBNull, error "cast from type DBNull to
type STRING is not valid"
Public Function NullStringCheck(ByVal Value As Object) As String
Select Case IsDBNull(Value)
Case True
Return ""
Case False
Return CStr(Value)
End Select
End Function
Please advise
Bob Day