Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Deleting master-detail records in ADOtable

Posted on 2001-06-13
1
Medium Priority
?
510 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 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

877 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