0
Try
    xConn.ConnectionString = xConnBuilder.ConnectionString
    xConn.Open()
    Throw New Exception("Something")
Catch ex As Exception
    Throw
Finally
    If xConn.State = ConnectionState.Open Then
        xConn.Close()
    End If
End Try

What happens to the connection object after the exception is thrown and re-thrown maintaining the stack trace, is it closed, because the finally block is not reached in case of exception.

Soham Dasgupta
  • 5,061
  • 24
  • 79
  • 125

2 Answers2

3

Finally block contains the code that must be executed no matter weather there was an error/exception or not.

4b0
  • 21,981
  • 30
  • 95
  • 142
1

In your sample code the connection will be closed. The finally code block is always executed irrespective of exception occurs or not.