delete from multiple tables with one button
Posted on 2005-03-28
I have 10 tables (ADOTable)
I display them in grid by means of radiobuttons i.e like this :
procedure TForm11.BitBtn1Click(Sender: TObject);
Case Radiogroup1.ItemIndex of
for i:= 0 to Form11.ComponentCount - 1 do
if (Form11.Components[i] is TADOTable) then
(Form11.Components[i] as TAdoTable).Close;
and so on for the remaining 9 tables.
Now,I added a query (ADOQuery1) so I can do some cleanup
with it.The basic cleanup parameters that I use to clean up tables
are the Autoinc field (ID) and the date field.
AdoQuery1.SQL.Text:='delete from USERSLOG where USERSLOG.DATE between :d1 and :d2';
AdoQuery1.SQL.Text:='delete from log where log.id between :d1 and :d2';
The problem is I would like to do cleanup with just one button.
So I guess I must tell the button on which table exactly to run the cleanup queery.
How do I do that???
I guess it could be done with stored procedures but I never used them before .
Baahh...Tell me your opinion and a solution.