Delphi遍历ADO数据集遍历操作

Delphi数据库应用程序通过数据存取构件对数据库进行访问和操作非常方便

下面通过代码演示

procedure Treturn_doc_NoForm.dbcbbIssue_NoClick(Sender: TObject);
var
  str:string;
  adoQ:TADOQuery;
begin
    DBComboBox1.Items.Create;
    adoQ:=TADOQuery.Create(nil);//创建ado
    adoQ.Connection:=DataModule1.con2;//给ado制定数据库
    str:=dbcbbIssue_No.Text;//可通过str对数据进行条件查询
    adoQ.SQL.Text:='select distinct order_number from Issue where issue_id='''+str+'''';//制定sql语句
    adoQ.Open;//打开ADO
    while not adoQ.Eof do//判断查询的数据是否为空
    begin
          str:=adoQ.FieldByName('order_number').AsString;//获取第一条数据的order_number的值
          DBComboBox1.Items.add(str);
          adoQ.Next;//下一条数据
    end;
  adoQ.free;

end;

如果对大家呀帮助麻烦给个赞吧谢谢

你可能感兴趣的:(Delphi,交互)