var i,j:integer;fn:string;begindatasource2.DataSet.Fielddefs.Clear;for I :=0 to datasource1.DataSet.Fields.count - 1 dobegin datasource2.Dataset.FieldDefs.Add(datasource1.DataSet.Fields.FieldName,datasource1.DataSet.Fields.DataType);end;datasource2.Createdataset;for I :=0 to dbgrideh1.SelectedRows.count -1 dobegin dbgrideh1.Datasource.dataset.GotoBookmark(pointer(dbgrideh1.SelectedRows.items)); datasource2.dataset.Append; for J :=0 to dbgrideh1.Datasource.dataset.Fields.Count - 1 do begin FN :=dbgrideh1.Datasource.dataset.Fields[j].FieldName; datasource2.DataSet.FieldByName(FN).Value :=dbgrideh1.Datasource.dataset.FieldByname(FN).Value; end; datasource2.Dataset.post;end;end;procedure TForm1.FormCreate(Sender: TObject);beginwith adoquery1 do begin close; sql.Clear; sql.Add('select * from hz_grou'); open; active:=true;end;end;end.to liurui525:谢谢您,我改后能编译通过,但执行时出错