if you are using SQL Server, tryselect c.* from syscolumns c, sysobjects t where c.id = t.id and t.type='U' and t.name='YourTableName'

解决方案 »

  1.   

    求出字段名,其它的也差不多
    var icount:integer;
    begin  
      //先要open  select * from 表名
      for icount:=0 to AdoDataSet1.Fields.count-1 do
          listbox1.items.add(AdoDataset1.fields[icount].Fieldname);  
    end;
      

  2.   

      if dm1.CDSTmp.Active = true then dm1.CDSTmp.EmptyDataSet;
      dm1.CDSTmp.Close;
      dm1.CDSTmp.FieldDefs.Clear;
      for i := 0 to dm1.QryMain.FieldCount - 1 do
      begin
        with dm1.CDSTmp.Fielddefs.AddFieldDef do
        begin
          name := dm1.QryMain.Fields[i].FieldName;
          datatype := dm1.QryMain.Fields[i].DataType;
          required := dm1.QryMain.Fields[i].required;
        end;
      end;
      dm1.CDSTmp.CreateDataSet;
      

  3.   

    用GETFIELDNAME或者GetFieldList
    Retrieves a list of names for all fields in a fields object.procedure GetFieldNames(List: TStrings);DescriptionCall GetFieldNames to get a list of names for all fields in a fields object. List is a TStrings (or compatible) object created and maintained by the application.Retrieving a list of field names is especially useful for applications that work with datasets whose field objects are created dynamically at runtime. By retrieving a list of field names, the application can be restricted to working only with fields that exist at runtime.Retrieves a specified set of field objects into a list.procedure GetFieldList(List: TList; const FieldNames: string);DescriptionCall GetFieldList to copy a specified set of field objects into a list object created and maintained by the application.List is the TList object into which to copy the field objects. FieldNames is a string containing the name of the fields to copy. Each field name in the string must be separated from other field names with a semicolon. GetFieldList builds a list that contains only the field objects for which it finds a matching name in the dataset抯 list of field objects.Note: Applications do not normally call GetFieldList to copy field objects. Field objects are directly accessible through the dataset itself. In some cases, however, it can be useful to work with a copy of a field object or its data instead of working on the actual object in the dataset.