Saturday, January 23, 2010

Handle Database Null Values in VB.NET/ASP.NET

Handle Database Null Values in VB.NET/ASP.NET


Public Function IsDBNull(ByVal dbvalue) As Boolean
Return dbvalue Is DBNull.Value
End Function

Public Function FixNull(ByVal dbvalue) As String
If dbvalue Is DBNull.Value Then
Return ""
Else
'NOTE: This will cast value to string if
'it isn't a string.

Return dbvalue.ToString
End If
End Function




happy programming
Asma Qureshi

No comments:

Post a Comment