同一个表(A)中的两条数据ID分别为1、2,有两个字段F1、F2,我如何才能实现将ID=1中的数据复制到ID=2的记录中阿?

解决方案 »

  1.   

    var
    i:integer;
    begin
    adotable1.Edit;
    adotable1.Last;
    adotable1.Insert;
    for i:=0 to DBGrid1.FieldCount-1 do
    begin
    if adotable1.Fields[i].DataType = ftstring then adotable1.Fields[i].AsString:='';
    if adotable1.Fields[i].DataType = ftdatetime then adotable1.Fields[i].Value:=date();
    if adotable1.Fields[i].DataType = ftinteger then adotable1.Fields[i].Value:=0;
    if adotable1.Fields[i].DataType = ftfloat then adotable1.Fields[i].Value:=0;
    if adotable1.Fields[i].DataType = ftboolean then adotable1.Fields[i].Value:=true;
    end;
    adotable1.Post;
    adotable1.Refresh;  //刷新记录
    DBGrid1.Refresh;
    refresh;
    DBGrid1.SetFocus;
      

  2.   

    还有好一点方法吗?通过Update能实现吗?