I am getting this exception from the following VB.NET code for only certain months:
System.InvalidCastException: Conversion from type \'DBNull\' to type \'Da
I use a sub (different for each datatype) to get data from a Datareader, using the index instead of the name though:
#If Access Then
_
Friend Function GetDbStringValue(ByVal Dr As OleDbDataReader, ByVal nr As Integer) As String
#Else
_
Friend Function GetDbStringValue(ByVal Dr As MySqlDataReader, ByVal nr As Integer) As String
#End If
If IsDBNull(Dr.Item(nr)) Then
Return ""
Else
Return Dr.GetString(nr).TrimEnd
End If
End Function