0
Follows 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 even so gives this error, could you help me? my logic is correct?
You’re using it here
if ZQuery2.RecordCount > 1 then ZQuery2.Next;
So, the next one right, about Zconnrepara, I figured it out and I pulled it out, I’m gonna test theKeepConnection
.– Ramon Ruan
No man, look inside your while not zQuery2.eof. In no time you give a zQuery2.next. I will edit my reply and show you how I think it would be.
– Edgar Muniz Berlinck
Oh yes man, kkkk, damn it, it was my msm mistake, is that the code was not complete :/ , sorry there
– Ramon Ruan
@Ramonruan I edited the answer considering that your while is the way I posted.
– Edgar Muniz Berlinck