Solved

Deleting master-detail records in ADOtable

Posted on 2001-06-13
1
486 Views
Last Modified: 2010-04-06
Dear Sir,

I have two tables Access2000 in master-detail relationship. I access them using ADOtable. In a form, when I try to delete the master records, a message comes out saying there's detail records, then I delete detail records first and when I try to delete master records the same message stops me from deleting them. In Delphi demo folder there's in db one sample named dberrors.dpr, however it uses BDE to delete master-detail records. I don't want to use BDE. How do I do it using ADOtable, Ado connection?

Thanks,

Rhiegen
0
Comment
Question by:rhiegen
1 Comment
 
LVL 3

Accepted Solution

by:
Stefaan earned 100 total points
ID: 6189725
Hi,

If the database is an Access2000 database, you can set up cascaded deletes.  If you set those up it should give no problem anymore ( though personally I don't use that ).  Just open the DB, go to the Relationship diagram and find your master table.  Now klick on the links with the other tables and select 'Edit Relationship', and a new dialop will open in which you can enable 'Cascade Delete Related records'

This will set up your DB so that if you delete a master record, it will automatically delete the detail records.

If you do not want to set up Cascade deletes in your database, you will have to do it programmatically in your application.  Maybe in the BeforeDelete event of the Master table you can loop over all records from every detail table to delete them so that the actual delete of the master record will succeed.

I hope this will be of any help to you,


Best regards,


Stefaan
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question