大哥:
   我想把用query控件查找出来的记录,修改它们的其中一个字段。
用下列代码选记录,想把选出来的记录的某个字段值附值为从1到n
with query1 do
 begin
  close;
  with sql do
   begin
    clear;
    add('select * from danxuan');
    add('order by Knowledgepoint');
   end;
   open;
  end;

解决方案 »

  1.   

    首先不能用 order by ,group by 等语句,并且必须是单表设置CachedUpdates:=true;
    RequestLive:=true;
      

  2.   


    query1.First
    while not query1.Eof do
    begin
      query1.Edit;
      query1.FieldByName('字段名').AsInteger:=query1.RecNo;
      query1.Post;
      query1.Next;
    end;
      

  3.   


      Query1.first;
      while not Query1.Eof then
        if (满足条件) then
        begin
          Query1.fields[i].AStype:= //--you wanted;and the type you   
                                                              //needed
          next;
        end;
      

  4.   

    with query1 do
     begin
      close;
      with sql do
       begin
        clear;
        add('select * from danxuan');
        add('order by Knowledgepoint');
       end;
       open;
      end;query1.first;
    for i:=0 to query1.RecordCount-1 then
    begin
      query.FieldByName(字段名).value:=i+1;
      query.post;
      query.next;
    end;
      

  5.   

    错了
      Query1.first;
      while not Query1.Eof then
        if (满足条件) then
        begin
          Query1.fields[i].AStype:= //--you wanted;and the type you   
                                                              //needed
          Query1.next;
        end;
      

  6.   

    用DBGride控件可以看到值了
    就是文件里没有值!
      

  7.   

    query1.active:=true;
    with query1 do
     begin
      close;
      with sql do
       begin
        clear;
        add('select * from danxuan');
        add('order by Knowledgepoint');
       end;
       open;
      if query1.recordcount>0 then
        begin
         query1.edit
       .................
         query1.applyupdatas;
         query1.commiupdatas;
      end;