procedure TForm3zonghe.FormShow(Sender: TObject); var sqlstrl:string; query:TADOQuery; begin //sqlstrl:='select * from banji'; //显示当前班级信息 //ADOQuery1.close; //ADOQuery1.SQL.Clear; //ADOQuery1.SQL.Text:=sqlstrl; //ADOQuery1.Open; DBCombobox1.Items.Clear; //将班级信息加入组合框 query:=TADOQuery.Create (self); query.ConnectionString:=ADOQuery1.ConnectionString; query.SQL.clear; sqlstrl:='select distinct ClassNo from banji'; query.SQL.Text:=sqlstrl; query.open; query.first; while not Query.Eof do begin DBCombobox1.Items.Add(Query.FieldByName('ClassNo').asstring); query.Next; end; DBCombobox2.Items.Clear; //将课件信息加入组合框 query:=TADOQuery.Create (self); query.ConnectionString:=ADOQuery1.ConnectionString; query.SQL.clear; sqlstrl:='select distinct CName from Course'; query.SQL.Text:=sqlstrl; query.open; query.first; while not Query.Eof do begin DBCombobox2.Items.Add(Query.FieldByName('CName').asstring); query.Next; end;end;
这个是COMBOBOX的,你自己比一下看能不能.用到DBCOMBOBOX上VAR I:integer; begin i:=0; combobox2.clear; query2.Close; query2.SQL.Clear; query2.sql.add('select distinct bm from bm'); query2.open; for i:=0 to query2.RecordCount-1 do begin combobox2.Items.add(query2.fieldbyname('bm').asstring); query2.Next; end;
var
sqlstrl:string;
query:TADOQuery;
begin
//sqlstrl:='select * from banji'; //显示当前班级信息
//ADOQuery1.close;
//ADOQuery1.SQL.Clear;
//ADOQuery1.SQL.Text:=sqlstrl;
//ADOQuery1.Open; DBCombobox1.Items.Clear; //将班级信息加入组合框
query:=TADOQuery.Create (self);
query.ConnectionString:=ADOQuery1.ConnectionString;
query.SQL.clear;
sqlstrl:='select distinct ClassNo from banji';
query.SQL.Text:=sqlstrl;
query.open;
query.first;
while not Query.Eof do
begin
DBCombobox1.Items.Add(Query.FieldByName('ClassNo').asstring);
query.Next;
end;
DBCombobox2.Items.Clear; //将课件信息加入组合框
query:=TADOQuery.Create (self);
query.ConnectionString:=ADOQuery1.ConnectionString;
query.SQL.clear;
sqlstrl:='select distinct CName from Course';
query.SQL.Text:=sqlstrl;
query.open;
query.first;
while not Query.Eof do
begin
DBCombobox2.Items.Add(Query.FieldByName('CName').asstring);
query.Next;
end;end;
I:integer;
begin
i:=0;
combobox2.clear;
query2.Close;
query2.SQL.Clear;
query2.sql.add('select distinct bm from bm');
query2.open;
for i:=0 to query2.RecordCount-1 do
begin
combobox2.Items.add(query2.fieldbyname('bm').asstring);
query2.Next;
end;