Repair on Checked Tables

0

Follow the code:

status := DataModule1.ZQuery2.FieldByName('Msg_text').AsString;
  while not DataModule1.ZQuery1.Eof do
  begin
    if status <> 'OK' then
    begin
      DataModule1.ZQuery3.Close;
      DataModule1.ZQuery3.SQL.Clear;
      DataModule1.ZQuery3.SQL.Add('Repair tables ' + Parametro);
      DataModule1.ZQuery3.Open;
      ShowMessage(DataModule1.ZQuery3.Sql.Text);
    end
    else
    begin
    DataModule1.ZQuery1.Next;
    end;
  end;

With the help of Filipe.Fonseca, I was able to check the items below.

Check in the tables that appear in my first DBGrid

I just want it to work if Msg_Text is not OK, it does Repair . Could someone help me?

    
asked by anonymous 21.05.2014 / 15:57

1 answer

0

Once again you're messing with the Queries. Set "friendly" names to not give next in the wrong Query, for example QryTabelas , QryStatus , etc.

Try this:

   
while not DataModule1.ZQuery2.Eof do
begin
  status := DataModule1.ZQuery2.FieldByName('Msg_text').AsString;
  if status <> 'OK' then
  begin
    DataModule1.ZQuery3.Close;
    DataModule1.ZQuery3.SQL.Clear;
    DataModule1.ZQuery3.SQL.Add('Repair tables ' + Parametro);
    DataModule1.ZQuery3.ExecSQL;
    ShowMessage(DataModule1.ZQuery3.Sql.Text);
  end
  DataModule1.ZQuery2.Next;
end;
    
21.05.2014 / 19:35