title: Checking whether value is DBNull
body: <p>I have the following function:</p>
  
  <pre><code>Public Shared Function imageExists(ByVal path As Object) As Boolean
                  If IsDBNull(path) = False Or Not path Is Nothing Then
                      Dim pathString As String = Convert.ToString(path)
                      If Exists(HttpContext.Current.Server.MapPath(path)) Then
                          Return True
                      Else
                          Return False
                      End If
                  Else
                      Return False
                  End If
  
              End Function
  </code></pre>
  
  <p>Called by the visible property for this image control:</p>
  
  <pre><code>&lt;asp:Image ID="img_SmallImage" runat="server" ImageUrl='&lt;%# "~/Content/Images/Exclusive/" + Eval("trip_SmallImage") %&gt;' Visible='&lt;%# OnTheMain.Images.Validation.imageExists(Eval("trip_SmallImage"))%&gt;' /&gt;
  </code></pre>
  
  <p>No matter what I try for the <code>If IsDBNull</code> part, it either ignores it and executes the code, or returns an error such as <code>Conversion from type 'DBNull' to type 'String' is not valid.</code></p>
  
  <p>How can I rectify the situation?</p>