Ver Mensaje Individual
  #4  
Antiguo 30-09-2003
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Reputación: 10
marcoszorrilla Va por buen camino
Prueba con este procedimiento que yo utilizo con las tablas Paradox y me va perfectamente:

Código:
Procedure midberror(DataSet: TDataSet; E: EDatabaseError);

…….

Const
  eKeyViol = 9729;
  eRequiredFieldMissing = 9732;
  eForeignKey = 9733;
  eDetailsExist = 9734;
  eSqlGralerror = 13059;
  eInvalidTime = 10058;
  eInvalidDate = 75;   
  EinvalidDateTime=10060;
  eRegisterLocked= 10241;

implementation

……

Procedure midberror(DataSet: TDataSet; E: EDatabaseError);
var
mierror:double;
begin

mierror:= (E as EDBEngineError).Errors[0].Errorcode;


if (E is EDBEngineError) then
    if (E as EDBEngineError).Errors[0].Errorcode = eKeyViol then
    begin
      Application.MessageBox('Imposible dar alta ese registro ya existe','Atención',mb_Ok +
mb_IconQuestion);
      Abort;
      end;

if (E as EDBEngineError).Errors[0].Errorcode = eRequiredFieldMissing then
    begin
      Application.MessageBox('Imposible dar alta hay un campo vacio.','Atención',mb_Ok +
mb_IconQuestion);
      Abort;
      end;

      if (E as EDBEngineError).Errors[0].Errorcode = eInvalidTime then
    begin
      Application.MessageBox('Formato de hora incorrecto.','Atención',mb_Ok +
mb_IconQuestion);
      Abort;
      end;

if (E as EDBEngineError).Errors[0].Errorcode = eInvalidDate then
    begin
      Application.MessageBox('Formato de fecha incorrecto.','Atención',mb_Ok +
mb_IconQuestion);
      Abort;
      end;

      if (E as EDBEngineError).Errors[0].Errorcode = eInvalidDateTime then
    begin
      Application.MessageBox('Formato de fecha-hora incorrecto.','Atención',mb_Ok +
mb_IconQuestion);
      Abort;
      end;
      
      //campo en blanco

      if (E as EDBEngineError).Errors[0].Errorcode =   eSqlGralerror then
    begin
      Application.MessageBox('Imposible dar alta hay un campo requerido vacío.','Atención',mb_Ok +
mb_IconQuestion);
      Abort;
      end;

//Registro bloqueado
    if (E as EDBEngineError).Errors[0].Errorcode =   eRegisterLocked then
    begin
      Application.MessageBox('Imposible hacer modificaciones registro bloqueado por otro usuario.','Atención',mb_Ok +
mb_IconQuestion);
      Abort;
      end;
      
end;

//aqui capturamos el error de bloqueo
procedure TdmoPalma.CliEditError(DataSet: TDataSet; E: EDatabaseError;
  var Action: TDataAction);
begin
midberror(cli,e);
end;

procedure TdmoPalma.CliPostError(DataSet: TDataSet; E: EDatabaseError;
  var Action: TDataAction);
begin
midberror(cli,e);
end;
Un Saludo.
__________________
Guía de Estilo de los Foros
Cita:
- Ça c'est la caisse. Le mouton que tu veux est dedans.
Responder Con Cita