经过测试,wxj9527所写的没有问题,那就是数据库表中不存在该字段。我把我的单元发一下,只是稍微修改了一下。unit Unit2;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CheckLst, DB, ADODB, Grids, DBGrids;type TForm2 = class(TForm) clb_source_field: TCheckListBox; clb_source_table: TCheckListBox; ADOConnection1: TADOConnection; ADO_Source: TADOQuery; btn_Commit: TButton; ADOQuery1: TADOQuery; DBGrid1: TDBGrid; DataSource1: TDataSource; procedure FormShow(Sender: TObject); procedure btn_CommitClick(Sender: TObject); procedure clb_source_tableClickCheck(Sender: TObject); private function GetCheckedStr(const checklistbox: TCheckListBox): string; { Private declarations } public { Public declarations } end;var Form2: TForm2;implementation{$R *.dfm}function TForm2.GetCheckedStr(const checklistbox: TCheckListBox): string;var i: integer;begin Result := ''; for i := 0 to checklistbox.Items.Count - 1 do begin if checklistbox.Checked then begin if Trim(checklistbox.Name) <> 'clb_source_field' then begin Result := checklistbox.Items.Strings; break; end else begin Result := Result + checklistbox.Items.Strings + ','; end; end; end; if Trim(checklistbox.Name) = 'clb_source_field' then begin if Trim(result) <> '' then Result := Copy(Result, 1, Length(Result) - 1) else Result := '*'; end;end;//从数据库中读取所有表的名称,放在clb_source_table中procedure TForm2.FormShow(Sender: TObject);var tbList: TStrings;begin tbList := TStringList.Create; try ADOConnection1.GetTableNames(tbList, false); clb_source_table.Items := tbList; finally tbList.Free; end;end;procedure TForm2.btn_CommitClick(Sender: TObject);var s1, s2: string;begin s1 := GetCheckedStr(clb_source_field); s2 := GetCheckedStr(clb_source_table); if Trim(s2) = '' then begin MessageDlg('请选择表名!', mtInformation, [mbok], 0); Exit; end; try with ADO_Source do begin Close; SQL.Clear; SQL.Text := 'select ' + s1 + ' from ' + s2 + ' '; //showmessage(SQL.Text); Open; end; except on e: Exception do MessageDlg(e.Message, mtError, [mbok], 0); end;end;//当选择了clb_source_table中的一条记录时,在clb_source_field中显示相应字段。procedure TForm2.clb_source_tableClickCheck(Sender: TObject);var i: Integer; tablename: string; fieldlist: TStrings;begin fieldlist := TStringList.Create; try try for i := 0 to clb_source_table.Items.Count - 1 do begin if clb_source_table.Checked then begin tablename := clb_source_table.Items.Strings; break; end; end; ADOConnection1.GetFieldNames(tablename, fieldlist); clb_source_field.Items := fieldlist; except on e: Exception do MessageDlg(e.Message, mtError, [mbok], 0); end; finally fieldlist.free; end;end;end.其中 ADO_Source,adoquery为一个adoquery,DBGrid1显示数据,adoconnection设置与数据库的连接。