请教:
如何实现用ListBox列出数据库中所有的表名?

解决方案 »

  1.   

    我有个读ORACLE的例程,如果要的话,请加我的QQ:28972303http://good.okey.net
    email:[email protected]
      

  2.   

    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;
      

  3.   

    如果是oracle,
    select * from all_talbes 得到表名插入
      

  4.   

    以下是使用adoconnection的例子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;
    这个是使用database
    Database1.GetTableNames(ListBox1.Items, False);
    这些方法都可以得到所有的表名,就看你用哪一种了
      

  5.   

    sql server  :  select * from information_schema.tables where ???
                   具体怎么写自己看看运行结果
    oracle:   select * from cat where ???