我利用ADOQuery查出了多条数据,我现在需要对每条数据进行处理,但我如果读取每条数据?ADOQuery.Fields[i]这好象只能读取第一条数据的第i列记录.

解决方案 »

  1.   

    你可以这样,
    adoquery.frist; 
    while not adoquery.eof do
    begin
      xxxxx
      adoquery.next;
    end;
      
      

  2.   


    for i:=1 to ADOQuery.RecordCount do
    begin
      string1:=//第i行2列数据
      string2:=//第i行3列数据
      {
       其他处理代码
      }
    end;
      

  3.   

    adoquery.frist; 
    while not adoquery.eof do 
    begin 
      string1:=adoquery.fields[0].asstring;
      string2:=adoquery.fields[1].asstring;
     //////嫌麻烦 用for循环 
      for i:=0 to adoquery.fields.count-1 do
      begin
         adoquery.next; 
    end; 
      

  4.   

    谢谢风之谷,我试过了,在处理最后加上ADOQuery.Next就对了.
      

  5.   

    adoquery.frist; 
    while not adoquery.eof do 
    begin 
      //读取数据库
      adoquery.next; 
    end; 
    {
    修改数据:
           adoquery.edit;
           //修改数据程序
            adoquery.post;
    添加数据:
           adoquery.Insert;
           //添加数据程序[也可用SQL操作]
            adoquery.post       
    }
      

  6.   

    with adoquery1 do
    begin
      close;
      sql.clear;
      sql.add('...');
      sql.open;  if recordcount >0 then
      begin
         while not eof do
         begin
            fields[i].asstring; //  i是第几列;
            next;
         end;
      end;