var sTableList: TStrings; begin sTableList:=TStringList.Create(); try adoConnection.Connected:=true; adoConnection.GetTableNames(sTableList,false); ShowMessage(sTableList.Text);//显示所有表名 finally sTableList.Free; end end; 但查询也包括进来了
procedure TForm1.Button1Click(Sender: TObject); var Li: tStrings; i: integer; begin Li := tStringList.Create; ADOConnection1.GetTableNames(Li, False); for i := 0 to Li.Count - 1 do begin memo1.Lines.Add(Li.Strings[i]); end; end;
procedure TForm1.Button1Click(Sender: TObject);var SL: TStrings; index: Integer; begin SL := TStringList.Create; try ADOConnection1.GetTableNames(SL, False); for index := 0 to (SL.Count - 1) do begin Table1.Insert; Table1.FieldByName('Name').AsString := SL[index]; if ADOTable1.Active then ADOTable1.Close; ADOTable1.TableName := SL[index]; ADOTable1.Open; Table1.FieldByName('Records').AsInteger := ADOTable1.RecordCount; Table1.Post; end; finally SL.Free; ADOTable1.Close; end; end;
sTableList: TStrings;
begin
sTableList:=TStringList.Create();
try
adoConnection.Connected:=true;
adoConnection.GetTableNames(sTableList,false);
ShowMessage(sTableList.Text);//显示所有表名
finally
sTableList.Free;
end
end;
但查询也包括进来了
ADOConnection1.GetTableNames(ListBox1.Items,False);//将所有表显示在ListBox1中
procedure TForm1.Button1Click(Sender: TObject);
var
Li: tStrings;
i: integer;
begin
Li := tStringList.Create;
ADOConnection1.GetTableNames(Li, False);
for i := 0 to Li.Count - 1 do
begin
memo1.Lines.Add(Li.Strings[i]);
end;
end;
SL: TStrings;
index: Integer;
begin
SL := TStringList.Create;
try
ADOConnection1.GetTableNames(SL, False);
for index := 0 to (SL.Count - 1) do begin
Table1.Insert;
Table1.FieldByName('Name').AsString := SL[index];
if ADOTable1.Active then ADOTable1.Close;
ADOTable1.TableName := SL[index];
ADOTable1.Open;
Table1.FieldByName('Records').AsInteger := ADOTable1.RecordCount; Table1.Post;
end;
finally
SL.Free;
ADOTable1.Close;
end;
end;