Fórum Problema com exclusao item master/detail #270505
28/02/2005
0
to usando delphi7 com interbase.
código do botao: tbdetail.delete;
definicao da fk: alter table detail
add constraint fk_detail foreign key(det_id) references master(mas_id)
valeu.
Eduunai
Curtir tópico
+ 0Posts
01/03/2005
Cabelo
Gostei + 0
01/03/2005
Eduunai
Gostei + 0
01/03/2005
Eduunai
Gostei + 0
02/03/2005
Guilherme
é o seguinte quando vou excluir o mestre logicamente tenho q apagar os detalhes pois se nao apagar vai ficar dados sem mestre ai o banco de dados fica realmente ´ZUADO´ entao estou usando o seguinte codigo
Lembrando q tbbanco_pai é o mestre e tbbanco_filho é o detalhe!
procedure TFrmBanco.TBBanco_PaiBeforeDelete(DataSet: TDataSet);
begin
TBBanco_Filho.First;
TBBanco_Filho.DisableControls;
while not TBBanco_Filho.Eof do begin
if TBBanco_FilhoCODCAD.Value = TBBanco_PaiCODCAD.Value then begin
TBBanco_Filho.Delete;
TBBanco_Filho.next;
end else
TBBanco_Filho.next;
end;
TBBanco_Filho.EnableControls;
TBBanco_Pai.Delete
end;
mas nao esta funcionando alguem sabe o q esta acontecendo ?
alguma opniao melhor ?!
Ja postei aki mesmo mas nao resolvi meu problema !!!
agradeço desde já !!!!!
Gostei + 0
02/03/2005
Eduunai
procedure TFrmBanco.TbL_PaiBeforeDelete(DataSet: TDataSet);
begin
with Tbl_filha do
begin
DisableControls;
try
First;
while not Eof do
Delete;
finally
EnableControls;
end;
end;
end;
E no codigo pra excluir o registro, se vc tiver usando um botao ou o que for, coloque :
Tbl_pai.delete;
Eu faço assim e funciona. Tenta aí e me fala se deu certo.
Gostei + 0
03/03/2005
Guilherme
so gostaria q vc me esplicase o codigo ......(se for possivel)
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)