Posted By

psybuck2002us on 08/05/10



Versions (?)

Convert database NULL value fields to any string

 / Published in: VB.NET

This code converts database NULL field values to a string. The first argument represents the field from the database (maybe a Datarow field) and the second argument is the optional string that should be returned if a NULL value is encountered. By default, the function returns an empty string value.

  1. Public Shared Function IsNullToString(ByVal _PossibleNullObject As Object, Optional ByVal _IfNullReturnString As String = "") As String
  2. If Not IsDBNull(_PossibleNullObject) Then
  3. Return _PossibleNullObject.ToString
  4. Else
  5. Return _IfNullReturnString
  6. End If
  7. End Function

Report this snippet  

You need to login to post a comment.