Call GetTableNames to retrieve a list of tables in the associated database. List is a TStrings descendant that receives the table names. Any existing strings are deleted from the list before GetTableNames adds the names of all tables in the database.SystemTables specifies whether the list of table names should include only the database抯 system tables. If SystemTables is True, only the system tables are added to List. If SystemTables is False, the list is filled with ordinary tables.For example, the following line fills a list box with the names of all tables in the database:Database1.GetTableNames(ListBox1.Items, False);如果包含系统表:
Database1.GetTableNames(ListBox1.Items, True);

解决方案 »

  1.   

    TSession.GetDataBaseName可以获得当前连接的所有的数据库。
     GetDatabaseNames(List: TStrings);//象这些东西都是返回了字符串列表!
    这是最上一层的操作,它还可以获得各种驱动!procedure GetDriverNames(List: TStrings);
    在这个层次上你可以对各个数据库进行操作。当然从这里也可以直接或的你要的各种信息!
    procedure GetTableNames(const DatabaseName, Pattern: String; Extensions, SystemTables: Boolean; List: TStrings);
    MyStringList := TStringList.Create;
    try
      Session.GetTableNames('DBDEMOS', '*.db',False, False, MyStringList);
      { Add the table names to a list box }
      ListBox1.Items = MyStringList;
    finally
      MyStringList.Free;
    end;
    下一层次,就是TDataBase,这个只能获得它这个数据库本身的所有的table
    procedure GetTableNames(List: TStrings; SystemTables: Boolean = False);
    Database1.GetTableNames(ListBox1.Items, False);
    她还可获得指定的表的字段:
    procedure GetFieldNames(const TableName: String; List: TStrings);
    Database1.GetFieldNames('Employee', ListBox1.Items);