So row("end_date")
is nullable? You can use the DataRow
-extension method Field
which supports nullable types and is strongly typed:
For Each row As DataRow In currentdriver.Rows
Dim endDate As Date? = row.Field(Of Date?)("end_date")
If endDate.HasValue AndAlso endDate.Value > Date.Now Then
currentdrivername = row.Field(Of String)("driver_name")
currentenddate = endDate.Value
Exit For ' otherwise you are overwriting these variables always '
End If
Next