Convert database NULL value fields to any string

/ Published in: VB.NET
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.