Master-Detail Problem

From: Hifni (hifni_at_vampire.net)
Date: 04/27/04

  • Next message: M. D'Costa: "Using ADOQuery in Windows Service Application"
    Date: 26 Apr 2004 22:26:46 -0700
    
    

    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've 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's Detail. Also is the same for the 2 History tables(table3 is the master and table4 as it's detail table).

    After Inserting records to table1 & table2 the user clicks a button to send the records it's 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.


  • Next message: M. D'Costa: "Using ADOQuery in Windows Service Application"
  • Quantcast