Obviar errores de Delphi !!Urgente
Publicado por Marina (64 intervenciones) el 13/02/2001 15:40:32
Tengo un programa con una estructura try ... except en la cual estoy
controlando los errores de la siguiente forma (adjunto código):
begin
try
if not vBase.InTransaction then
vBase.StartTransaction;
if not(vBase.IsSQLBased) and
not (vBase.TransIsolation = tiDirtyRead) then
vBase.TransIsolation := tiDirtyRead;
if vGraba then
vQuery.Post;
vQuery.ApplyUpdates;
vBase.Commit;
vQuery.CommitUpdates;
vQuery.Close;
if not (vQuery.Prepared) then
vQuery.Prepare;
vQuery.Open;
Result := True;
except on e: exception do
begin
if (E is EDBEngineError) then
if (E as EDBEngineError).Errors[0].Errorcode
= DBIERR_KEYVIOL then // 9729
MessageDlg('Nº de Legajo existente', mtWarning, [mbOK], 0)
else
MessageDlg(E.Message, mtWarning, [mbOK], 0)
else
MessageDlg(E.Message, mtWarning, [mbOK], 0);
if vBase.InTransaction then
vBase.Rollback;
Result := False;
end;
end;
El problema que tengo es el siguiente:
- cuando se me genera una clave duplicada me aparece el error de
delphi "key violation", y no lo puedo evitar ni ejecutando el
programa desde el explorador de Windows, ni cambiando todas las
opciones en TOOLS - DEBUGGER OPTIONS
- a continuación de este error me aparece el siguiente: "operation
aborted", detectando como si fuera un error de tipo exception, siendo
que el mensaje anterior "key violation" me confirma que es
controlando los errores de la siguiente forma (adjunto código):
begin
try
if not vBase.InTransaction then
vBase.StartTransaction;
if not(vBase.IsSQLBased) and
not (vBase.TransIsolation = tiDirtyRead) then
vBase.TransIsolation := tiDirtyRead;
if vGraba then
vQuery.Post;
vQuery.ApplyUpdates;
vBase.Commit;
vQuery.CommitUpdates;
vQuery.Close;
if not (vQuery.Prepared) then
vQuery.Prepare;
vQuery.Open;
Result := True;
except on e: exception do
begin
if (E is EDBEngineError) then
if (E as EDBEngineError).Errors[0].Errorcode
= DBIERR_KEYVIOL then // 9729
MessageDlg('Nº de Legajo existente', mtWarning, [mbOK], 0)
else
MessageDlg(E.Message, mtWarning, [mbOK], 0)
else
MessageDlg(E.Message, mtWarning, [mbOK], 0);
if vBase.InTransaction then
vBase.Rollback;
Result := False;
end;
end;
El problema que tengo es el siguiente:
- cuando se me genera una clave duplicada me aparece el error de
delphi "key violation", y no lo puedo evitar ni ejecutando el
programa desde el explorador de Windows, ni cambiando todas las
opciones en TOOLS - DEBUGGER OPTIONS
- a continuación de este error me aparece el siguiente: "operation
aborted", detectando como si fuera un error de tipo exception, siendo
que el mensaje anterior "key violation" me confirma que es
Valora esta pregunta


0