Solved

Deleting master-detail records in ADOtable

Posted on 2001-06-13
1
478 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Delphi function to get Youtube video title 5 223
Create a path if not exists 7 69
DBGrid or StringGrid ? 6 65
Not able to call Delphi XE10 dll function from Delphi 6.0 4 17
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now