Board index » delphi » Master-Detail Problem
Hifni
Delphi Developer |
Master-Detail Problem2004-04-27 01:26:46 PM delphi74 Hi, I want to know whether there any option in ADODataset, when a master records are deleted the detail Records are automatically delete itself(It should also support updates too). If so where can I set it or how can I do it? I'm completely stuck with this. I have 4 tables, two of the tables is for entry purposes(assume that the tables as table1 & table2), and the next 2 tables takes the role of History table(assume that these tables as table3 & table4). Table1 is the master, and table2 as it is Detail. Also is the same for the 2 History tables(table3 is the master and table4 as it is detail table). After Inserting records to table1 & table2 the user clicks a button to send the records it is History tables. If everything is successfully exported then I want to delete the inserted records in table1 & table2. I used a ADOQuery1 for first delete the Detail and Execute it. Then Used a another ADOQuery2 for delete the master and execute it in Entry Tables. I wrote the following code in a Transaction as: Try ADOConnection.BeginTrans; ADOQuery1.ExecSQL; ADOQuery2.ExecSQL; table1.Refresh; table2.refresh; ADOConnection.CommitTrans; Except on E:Exception do ADOConnection.RollbackTrans; End; However received the following errors: "Project ShareList.Exe raised exception class EOleException with message 'Key value for this row was changed or deleted at the data store. The local row is now deleted'. Process stopped. Use step or run to continue" and another one as: "Project ShareList.Exe raised exception class EOleException with message 'Row handle referred to a deleted row or a row marked for deletion'. Process stopped or Run to continue" Also it rollbacks the data and not gets deleted in entry tables. How can I do this process as an error free process. Awaiting somebodys answer. Thanx, nazeer. |