本人的代码如下: with adoquery2 do begin while not adoquery1.Eof do begin adoquery2.Close; adoquery2.sql.Clear; adoquery2.sql.Add('select * from ty3 where id between qishi and zhongzhi'); adoquery2.parameters.ParamByName('qishi').Value:=qishi; adoquery2.parameters.ParamByName('zhongzhi').Value:=zhongzhi; adoquery2.open; if adoquery2.RecordCount<>0 then begin adoquery2.edit; adoquery2.fields[1].Value:=(adoquery2.fields[1].Value)+(adoquery1.Fields[1].Value); adoquery2.post;
end else begin adoquery2.append; adoquery2.Fields[0].Value:=adoquery1.Fields[0].Value; adoquery2.Fields[1].Value:=adoquery1.Fields[1].Value; adoquery2.post;
with adoquery2 do begin FIRST; while not adoquery1.Eof do begin Close; sql.Clear; sql.Add('select * from ty3 where id between qishi and zhongzhi'); parameters.ParamByName('qishi').Value:=qishi; parameters.ParamByName('zhongzhi').Value:=zhongzhi; open; if RecordCount<>0 then begin Edit; fields[1].Value:=(fields[1].Value)+(adoquery1.Fields[1].Value); UpdateBatch;
end else begin append; Fields[0].Value:=adoquery1.Fields[0].Value; Fields[1].Value:=adoquery1.Fields[1].Value; UpdateBatch;
adoquery2.sql.Add('select * from ty3 where id between qishi and zhongzhi'); 改為﹕ adoquery2.sql.Add('select * from ty3 where id between :qishi and :zhongzhi'); 試試;