Buenas amig@s!!!
Tengo una funcion recursiva para realizar la conexion a BD (oracle),
pero resulta que cuando la llamada que se hace desde la propia funcion suelta una excepcion, esta no es recogida por el TRY CATCH y va directamente al final del TRY CATCH
la funcion es esta....
Function Conectar(ByVal i As Integer) As OracleConnection
Dim ocConexion As OracleConnection = Nothing
Dim sServer As String = ""
If i = 1 Then
sServer = "LOCALNEW"
ElseIf i = 2 Then
sServer = "pepe"
ElseIf i = 3 Then
sServer = "pepe"
ElseIf i = 4 Then
sServer = "localnew.Europe.Unity"
ElseIf i = 5 Then
sServer = "localnew.Europe.Unity".ToUpper
ElseIf i = 6 Then
sServer = "localnew.europe.unity"
End If
Try
ocConexion = New OracleConnection(My.Settings.pepeConnectionString. Replace("localnew", sServer))
ocConexion.Open()
Catch ex As Exception
If i < 6 Then
Conectar(i + 1)
Else
Alerta("No se ha podido conectar con la Base de Datos.")
End If
End Try
Return ocConexion
End Function