Delphi - Obviar errores de Delphi !!Urgente

 
Vista:

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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Obviar errores de Delphi !!Urgente

Publicado por JACOBO B. S. (80 intervenciones) el 13/02/2001 21:26:59
Puedes provar en el evento OnPostError del Query
procedure TForm1.Query1PostError(DataSet: TDataSet; E: EDatabaseError;
var Action: TDataAction);
begin
//Error al guardar
ShowMessage('Error en registro'+#13+
'Causa:'+E.Message);
Action:=daAbort;
end;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Obviar errores de Delphi !!Urgente

Publicado por novato (1 intervención) el 07/05/2007 18:03:54
Mira lo queyo ago en estos casos es

1.. si estas incertando primero busco si ya existe este registr en las tablas si existe pues mando un mensaje con algo como el registro con ese ID ya existe, cambio la P. Key

2.- oh puedes tratar el manejo de erroes
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar