There is probably is simple fix for this but I currently have code similar to
dim dr as dbDataReader
try
dr = connection.getDataReader(sql_str)
Catch ex as sqlClientException
log.error(ex)
finally
if not IsNothing(dr) then
dr.close
end if
end try
However Visual Studio still warns me that the
if not IsNothing(dr) then
dr.close
end if
Can cause a NullReferenceException. What is the best way to mitigate this? I can't move the declaration into the try block.