我要让程序能根据读取的数据库的表的不同,来显示出这张表所具有的各个字段名
我要怎么做
请高手教我
谢谢

解决方案 »

  1.   

    ADOConnection的方法,
    GetFieldNames(const TableName: String; List: TStrings);
    参数是表名,和字段列表。功能是把表的列读到一个List字符串数组里面
      

  2.   

    你再把List字符串数组里面的字符串循环读出来就是你那个表的字段。
      

  3.   

    读系统表
    sysobjects、syscolumns
    具体关联自己研究一下吧,很简单的,不过我忘了:)
      

  4.   

    1、根据表名取字段select rtrim(convert(char(20),syscolumns.name)) '字段名',
    convert(char(20),systypes.name) '类 型',
    syscolumns.length '长度'
    from syscolumns 
    left join systypes on systypes.xtype = syscolumns.xtype
    where id in
    (select id from sysobjects where name = 
    ltrim(rtrim('  D_Trans   ')))
    order by '字段名'
    --order by '类 型'
    2、取表名
    select convert(char(20),name) from 
    sysobjects where xtype ='u'
    order by name
      

  5.   

    也可以这样:
    select * from tablename where 1=2
    然后访问数据集中的字段
      

  6.   

    Session.GetFieldNames(databasename,tablename,ListBox.Items);