I have made a simple database containing two tables, one is the master of the other.
The first one is a table of files. The second is a table of discs that these files are stored on.
Files.db and Discs.db.
I have a query for showing this in a TDBGrid with the SQL below:
Select Files.FileName, Discs.Label from Files, Discs
where Files.Disc = Discs.ID
order by Files.FileName, Discs.Label
This query has an UpdateSQL connected to it.
I also have a separate Query for the discs with the following SQL:
Select ID, Label from Discs
This query is just for showing a list of the discs in a separate TDBGrid.
Now I want to be able to select a disc from the disc-grid and have my program to delete that disc from the database including all of its detail files. For this I have yet another query, the EraserQuery. Here's the SQL for that one:
Delete from Files
where Disc = :CurrentDisc
"CurrentDisc" is defined below, it is for the program to know which disc the user has selected. -
procedure TModules.DiscQueryBeforeDelete(DataSet: TDataSet);
EraserQuery.ParamByName('CurrentDisc').AsInteger := Discs.FieldByName('ID').AsInteger;
This works fine with the deletion and all, but it doesn't update the first query, the one showing all files and which disc they're on. It updates the tables and I have to restart my program for it to get updated. What can I do to fix this? Is there a better way deleting detailrecords?