procedure Tform3.Button1Click(Sender: TObject);
var
j,I,checkrow,mrow:integer;
mas: array of array of variant;
begin
 checkrow:=0;
 mrow:=0;
 form2.short:=tstringlist.create;
 form2.short.Clear;
form2.adoconnection1.GetTableNames(form2.short);
 if (form2.short.IndexOf(edit1.text)<>-1) and (edit1.text<>'') then
 begin
 
  for I := 1 to stringgrid1.RowCount-1 do
begin
  form2.adoquery3.SQL.Clear;
 form2.adoquery3.SQL.Text:='select [CATALOG] from ['+edit1.text+'] where [CATALOG]=:cd';
 form2.adoquery3.Parameters.ParamByName('cd').value:=stringgrid1.cells[0,i];
form2.adoquery3.execsql;
form2.adoquery3.open;
if form2.ADOQuery3.IsEmpty=true then
begin
 checkrow:=checkrow+1;
end;
end;
   checkrow:=checkrow+1;
 
  SetLength(mas,stringgrid1.colcount,checkrow);
 for I := 1 to stringgrid1.RowCount-1 do
begin
 
  form2.adoquery3.SQL.Clear;
 form2.adoquery3.SQL.Text:='select [CATALOG] from ['+edit1.text+'] where [CATALOG]=:cd';
 form2.adoquery3.Parameters.ParamByName('cd').value:=stringgrid1.cells[0,i];
form2.adoquery3.execsql;
form2.adoquery3.open;
if form2.ADOQuery3.IsEmpty=true then
begin
inc(mrow);
for j := 0 to stringgrid1.colcount-1 do
 mas[j,mrow]:=stringgrid1.cells[j,i] ;
 
end;
 
end;
 
for j := 0 to stringgrid1.colcount do
  StringGrid1.Cols[j].Clear;
 
   stringgrid1.rowcount:=checkrow;
   mrow:=0;
 
   with stringgrid1 do
   begin
   for i := 1 to rowcount-1 do
   begin
     inc(mrow);
 for j := 0 to colcount-1 do
cells[j,i]:=mas[j,mrow];
 end;
   end;
 
end;
 
 
statusbar1.panels[0].text:='Файл: '+opendialog1.FileName+', количество записей: '+inttostr(stringgrid1.rowcount-1);
end;