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?
Thanks!
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())