Autor Tema: REGONECTAR REGISTROS DE CONEXIONES PERDIDAS  (Leído 3331 veces)

0 Usuarios y 2 Visitantes están viendo este tema.

obethermy

  • Megabyte
  • ***
  • Mensajes: 116
  • Reputación: +6/-7
    • Ver Perfil
REGONECTAR REGISTROS DE CONEXIONES PERDIDAS
« en: Julio 16, 2016, 07:43:57 pm »

Código: (vb) [Seleccionar]
Function rec_des(strSQl As String) As ADODB.Recordset
On Error GoTo ErrorSQL
If RE_Conexion1 = False Then
    MsgBox "No se logró una conexión." & vbCrLf & "Intentado recuperar conexion.", vbCritical, "Mensaje"
    RE_Conexion
    Exit Function
End If
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open strSQl, con, ADODB.adOpenForwardOnly, ADODB.adLockBatchOptimistic
Set rs.ActiveConnection = Nothing
Set rec_des = rs
'con.Close
'Set con = Nothing
Exito:
    Exit Function
ErrorSQL:
    If Err.Number = -2147467259 Then
         MsgBox "Se perdio conexion." & vbCrLf & "Intentado recuperar conexion."
         con.Close
         Set con = Nothing
         RE_Conexion
         Resume Next
    Else
        ErroresSql Err.Number
        Resume Exito
    End If
End Function