title: properly dealing with null database values in vb.net
body: <p>I am looping thorugh a datatable and and printing each row to the console and I keep on getting a dbnull error.  I inserted an if statement in my loop to try and catch it, but I can't seem to get it to work.  Any ideas?</p>
  
  <p>Thanks!</p>
  
  <pre><code>                Do While reader.Read
                  For i As Integer = 0 To reader.FieldCount - 1
  
                      If reader.IsDBNull(i) Then
                          Console.Write(Nothing)
                      Else
                          Console.Write(reader.GetString(i))
                      End If
  
                  Next
                  Console.WriteLine(Environment.NewLine())
  </code></pre>