Delete rec in detail table
From: J Arty (jarty67_at_hotmail.com)
Date: 04/28/04
- Next message: RandChris: "Re: help with nested datasets and MSSql Server autoincrement, ado andD6"
- Previous message: Ian Tidy: "Re: Connection to MSDE 2000 A"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 28 Apr 2004 15:21:03 -0500
I have a master details form... when I delete the record in the master, I
want to be able to delete the detail records..
I am using Delphi 7, with sql 7...
In sql I can't put the id of the details table as primary because I need to
be able to put duplicates rec... therefore it is a foreign key with index
yes duplicates allowed...
if I use the relationship in sql and select cascade update s and deletes I
get an error, with the details key...
But when I run my code it deletes the record in the master but not in the
details, I have tested many different ways and saw that it is because the
table primary key is not the field I have in my delete sql, the details
primary key is an auto number...
here is the code I have:
DMmain.ADOConnection1.BeginTrans;
try
DMmain.ADOConnection1.Execute('Delete from table1 where table1ID ='+
inttostr(PId) );
DMmain.ADOConnection1.Execute('Delete from table2 where table2fkid = '+
inttostr(PId));
DMmain.ADOConnection1.CommitTrans;
Except
DMmain.ADOConnection1.RollBackTrans;
end;//try
I also tried
with AdoDelete do begin
Parameters.ParamByName('PID').Value := Pid;
Execute;
end;
but both of them execute without errors but when I go to the details table I
see the record is still there...
Any help would be greatly appreciated
- Next message: RandChris: "Re: help with nested datasets and MSSql Server autoincrement, ado andD6"
- Previous message: Ian Tidy: "Re: Connection to MSDE 2000 A"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|