.NET: Microsoft Technologies based on the .NET software framework. Runtime: An environment required to run apps that aren't compiled to machine language.
Hi,
if Connection Is Nothing you get NullReferenceException:
- Set Connection to Nothing
Dim Connection As SqlConnection = Nothing Dim bNeedAdd As Boolean = False Try Connection = CType(_Connections(ConnString), SqlConnection) Catch ex As Exception - Ignore Error if there isn't Connection in _Connections
End Try If Connection Is Nothing Then bNeedAdd = True End If If `Connection Is Nothing` OrElse ... Then Try Connection.Dispose() <--- Error line in 2019
Change your code:
If `Connection Is Nothing` OrElse ... Then
Try
Connection?.Dispose()