senad
asked on
delete from multiple tables with one button
I have 10 tables (ADOTable)
I display them in grid by means of radiobuttons i.e like this :
procedure TForm11.BitBtn1Click(Sende r: TObject);
Var I:integer;
begin
Case Radiogroup1.ItemIndex of
0: begin
for i:= 0 to Form11.ComponentCount - 1 do
if (Form11.Components[i] is TADOTable) then
(Form11.Components[i] as TAdoTable).Close;
ADOTable1.Open;
Datasource1.DataSet:=Adota ble1 ;
end;
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.
Example :
Adoquery1.Close;
Adoquery1.SQL.Clear;
AdoQuery1.SQL.Text:='delet e from USERSLOG where USERSLOG.DATE between :d1 and :d2';
adoquery1.Parameters.Param ByName('d1 ').Value:= DateToStr(DateTimePicker1. Date);
adoquery1.Parameters.Param ByName('d2 ').Value:= DateToStr(DateTimePicker2. Date);
Adoquery1.ExecSQL;
AdoTable3.Requery();
or
Adoquery1.Close;
Adoquery1.SQL.Clear;
AdoQuery1.SQL.Text:='delet e from log where log.id between :d1 and :d2';
adoquery1.Parameters.Param ByName('d1 ').Value:= Edit1.Text;
adoquery1.Parameters.Param ByName('d2 ').Value:= Edit2.Text;
Adoquery1.ExecSQL;
AdoTable1.Requery();
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.
I display them in grid by means of radiobuttons i.e like this :
procedure TForm11.BitBtn1Click(Sende
Var I:integer;
begin
Case Radiogroup1.ItemIndex of
0: begin
for i:= 0 to Form11.ComponentCount - 1 do
if (Form11.Components[i] is TADOTable) then
(Form11.Components[i] as TAdoTable).Close;
ADOTable1.Open;
Datasource1.DataSet:=Adota
end;
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.
Example :
Adoquery1.Close;
Adoquery1.SQL.Clear;
AdoQuery1.SQL.Text:='delet
adoquery1.Parameters.Param
adoquery1.Parameters.Param
Adoquery1.ExecSQL;
AdoTable3.Requery();
or
Adoquery1.Close;
Adoquery1.SQL.Clear;
AdoQuery1.SQL.Text:='delet
adoquery1.Parameters.Param
adoquery1.Parameters.Param
Adoquery1.ExecSQL;
AdoTable1.Requery();
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I had it working another way but this way is simpler ...Thank's Geo...
My pleasure :-)
ASKER
Var CurrentQuery:TADOQuery
then drop multiple queeries (for every radiobutton) and on button click
if TRadioButton(radioGroup1.C
then
Currentquery:=ADOQuery1
begin
something like this.... ???