Ver Mensaje Individual
  #5  
Antiguo 08-07-2013
elrodrix elrodrix is offline
Miembro
NULL
 
Registrado: nov 2011
Posts: 32
Reputación: 0
elrodrix Va por buen camino
Listo, pude solucionar este pequeño problema, agregando un TApplicationEvents en el Form Principal y con el siguiente codigo en el evento On Exception

Código Delphi [-]
//procedimiento para capturar las fallas en la perdida de conexion de la base de datos
//agregar ComObj en uses del FORM
procedure TFMain.ApplicationEvents1Exception(Sender: TObject; E: Exception);
var
  EO:EOLEException;
begin
  if E is EOLEException then
  begin
    EO:=EOLEException(E);
    if EO.ErrorCode = -2147467259 then
      //error de conexion (disconnected)
      begin
        try
          try
            DM1.ADOConnection1.Close;
          except;
          end;
          DM1.ADOConnection1.Open;
          ShowMessage('FALLA EN LA CONEXION A LA BASE DE DATOS - Reestableciendo, vuelva a intentar!');
        except
          on E:Exception do
            ShowMessageFmt('FALLA EN LA CONEXION A LA BASE DE DATOS!.  '
            + 'Por favor, intente luego!.'#13'Error message: %s', [E.Message]);
          end;
      end
      else
        ShowMessage(E.Message + ' ' + IntToStr(EO.ErrorCode));
    end
  else
    ShowMessage(E.ClassName + #13 + E.Message);
end;

Espero que les sirva. Gracias y Saludos
Responder Con Cita