delphi.gif (306 バイト) テーブルを移動するには


テーブル(一般にデータセット)の内容を別のテーブルに移動するには、BatchMoveコンポーネントとを使います。

移動方法の指定にはBatchMoveコンポーネントのModeプロパティを設定します。そして、SourceとDestinationプロパティにそれぞれのテーブルを指定したら、最後にExecuteメソッドを実行します。

delphi1.gif (322 バイト)

procedure TMainForm.btnExecuteClick(Sender: TObject);
begin
  Table1.TableName := Edit1.Text;
  Table2.TableName := Edit2.Text;
  BatchMove1.Source := Table1;
  BatchMove1.Destination := Table2;
  case ComboBox1.ItemIndex of
    0: BatchMove1.Mode := batAppend;
    1: BatchMove1.Mode := batUpdate;
    2: BatchMove1.Mode := batAppendUpdate;
    3: BatchMove1.Mode := batCopy;
    4: BatchMove1.Mode := batDelete;
  end;
  BatchMove1.Execute;
  MessageDlg('テーブルの移動が終了しました。', mtInformation, [mbOK], 0);
end;