在Delphi中的下拉框ComboBox怎么连数据库 Fieldbyname的用法2007-04-13 22:50:36 在Delphi中的下拉框怎么连数据库阿
ADOConnection1,AdoQuery1,button1,combobox1 各一个。 比如说点一下button1,将数据库内容填入到combobox1中 1、AdoConnection1的ConnectionString设置一下 2、AdoQuery1的Connection属性,选择AdoConnection1 3、procedure TForm1.Button1Click(Sender: TObject); begin with AdoQuery1 do begin close; sql.clear; sql.add('select distinct a from table'); open; combobox1.items.clear; while not eof do begin combobox1.items.add(fieldbyname('a').asstring); next; end; end; end; --------------------------------------- Fieldbyname的用法 (teacherDM.loginAdoQuery.fieldByName('password').asString<>Trim(passwordEdt.Text)) --- query1.append; query1.fieldbyname('字段1').value := xxx; query1.fieldbyname('字段2').asstring := xxxx; query1.fieldbyname('字段3').asinteger := xx; ... query1.post; |
|