My code block is below. As it turns out, rdrCurrentRate.GetString(12) is a null value, but the code block throws an error. “Data is Null. This method or property cannot be called on Null values.”
My intention is to write “if rdrCurrentRate.GetString(12) is NOT NULL, then sCurrentRateType = rdrCurrentRate.GetString(12)”
What am I missing here?
If Not String.IsNullOrEmpty(rdrCurrentRate.GetString(12)) Then
sCurrentRateType = rdrCurrentRate.GetString(12)
End If
You probably want to use the
IsDBNullmethod instead:Null values are not represented by
nullin the data reader, but instead of a specialDBNullvalue. TheIsDBNullmethod will check if the column represents such a value.