Follow the code:
ZQuery1.Close;
ZQuery1.SQL.Clear;
ZQuery1.SQL.Add('SHOW TABLES FROM '+zConnRepara.Database);
ZQuery1.Open;
ZQuery1.First;
Progressbar1.Max := ZQuery1.RecordCount;
lTemp := '';
Parametro := '';
//nomeDoDB'.'db.table := db.db.table
Parametro := zConnRepara.Database + '.' +
ZQuery1.FieldByName('Tables_in_' +
zConnRepara.Database).asString;
if ZQuery1.RecordCount > 1 then
ZQuery1.Next;
//check
while not ZQuery1.Eof do
begin
Parametro := Parametro + ',' + zConnRepara.Database + '.' +
ZQuery1.FieldByName('Tables_in_' +
zConnRepara.Database).asString;
ZQuery1.Next;
end;
ZQuery2.Close;
ZQuery2.SQL.Clear;
ZQuery2.Sql.Text := 'Check table ' + Parametro;
ZQuery2.Open;
CloseQuery;
if ZQuery2.RecordCount > 1 then
ZQuery2.Next;
lTemp := '';
//ProgressBar1.Position := 0;
//repair
while not ZQuery2.Eof do
begin
try
status := ZQuery2.FieldByName('Msg_text').AsString;
if (status <> 'OK') and (status = 'Corrupt') then
begin
zConnRepara.Connected := true;
inc(i);
ZQuery3.Close;
ZQuery3.SQL.Clear;
ZQuery3.SQL.Add('Repair table '+ Parametro);
ZQuery3.ExecSQL;
lTemp := lTemp + ',' + ZQuery2.FieldByName(
'Table').AsString;
StatusBar1.Panels[0].Text := 'Tabela sendo reparada: '+lTemp;
zConnRepara.Connected := false;
end;
except
on e: Exception do ShowMessage(''+e.Message);
end;
My question, is that the code is correct, and still gives this error, could you help me? Is my logic correct?