?
Solved

Deleteing from some tables....

Posted on 2000-02-24
6
Medium Priority
?
161 Views
Last Modified: 2010-04-04
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);
begin
  EraserQuery.ParamByName('CurrentDisc').AsInteger := Discs.FieldByName('ID').AsInteger;
  EraserQuery.Prepare;
  EraserQuery.ExecSQL;
end;


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?

regards,

Johan
0
Comment
Question by:sageryd
  • 2
  • 2
  • 2
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2555031
does a close and reopen of the first query not solve the problem without starting the whole app?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2555146
A Refresh should normally do fine.

(Question: Is the query updated when you move a record in the first table and then move back to the record)
0
 
LVL 1

Author Comment

by:sageryd
ID: 2555345
It works when i close and re-open the first query, but then I lose the selection the use might have. Is there another way? Refresh doesn't work.

johan
0
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!

 
LVL 8

Expert Comment

by:ZifNab
ID: 2555365
Hi sageryd,

perhaps bookmarking it, before closing? (don't know if this works)

Or, get the recordnumber  (thus position of record)

and then after closing do a  

query.First (not needed I think)
query.MoveBy(recordnumber) ?

Zif.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 400 total points
ID: 2555533
hi zif,

recordnumber is not on all databases properly filled,
also it is not properly filled, if not all records are fetched.

sageryd,
if zif suggestion will not work,
then save a unique fieldvalue into a var and
after open the query do a locate with it

meikl
0
 
LVL 1

Author Comment

by:sageryd
ID: 2555782
well, ok thanx! I guess Meikl should get the points as he was the first to give an answer.

Thanks again!


regards,

Johan
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

839 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