Ver Mensaje Individual
  #1  
Antiguo 10-05-2004
KaTo KaTo is offline
Registrado
 
Registrado: may 2004
Posts: 6
Reputación: 0
KaTo Va por buen camino
Problemas Con ADOquery y Tablas Relacioanadas

Hola Amigos tengo el siguiente problema
Mi BD es esta formada por 2 tablas relacionadas .
AREA.
- depto
- rut_area
- observaciones
PERSONAL
- rut_personal
- nombre
- direccion
- fono

utilizo los siguientes controles
adoconnection ---> mi coneccion a la BD
adoquery1--> sql---> Select * from personal

Mi codigo es asi
if key=#13 then // presiono enter y busca rut(es un codigo)
begin
adoquery1.Close ;
with adoquery1 do begin
with sql do begin
clear;
add('Select * from personal where rut_personal='''+edit1.Text+'''');
open;
end;
end;
adoquery1.first;
if adoquery1.Eof then
begin
showmessage ('datos no encontrados');
end
else
begin
edit2.Text :=adoquery1.FieldValues ['nombre']; // los despliego por pantalla
edit3.Text :=adoquery1.FieldValues ['direccion'];
edit4.Text :=adoquery1.FieldValues ['fono'];

end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject); // boton de eliminacion
begin
try
adoquery1.SQL.Clear ;
adoquery1.sql.Add('delete from personal where rut_personal='''+edit1.Text+'''');
adoquery1.ExecSQL ;
showmessage ('datos eliminados');
except
adoquery1.Cancel ;
raise;
end;
end;

AHORA CUANDO PRESIONO EL BOTON DE ELIMINACION DE REGISTRO ME DESPLIEGA EL SIGUIENTE ERROR:
"EL REGISTRO NO SE PUEDE ELIMINAR O CAMBIAR PORQUE LA TABLA 'AREA' INCLUYE REGISTROS RELACIONADOS"
ALGUIEN ME PODRIA DAR UNA MANO COMO PODER MOSTRAR ALGUN CUADRO DE MENSAJE DANDOLE EL AVISO DE
QUE EL REGISTRO ESTA SIENDO UTILIZADO Y QUE NO SE PUEDE ELIMINAR O COM PODER INTERSEPTAR EL ERROR

YA QUE PROBE CON TRY EXCEPT PERO NO SE COMO PRODRIA SER LA SOLUCION.
LES AGRADECERIA UN EJEMPLO GRACIAS

LES SALUDA KaTo
Responder Con Cita