The following code uses the BatchMove component to add records to a table. After the records have been added, the number of new records is reported on the status line.with BatchMove1 dobegin Mode := batAppend; AbortOnKeyViol := False; Execute; StatusBar1.SimpleText := IntToStr(MovedCount - KeyViolCount) + ' records added';end;
The following example uses a batch move component to move the contents of a query to the table chosen from a save dialog. The Exit procedure allows the event handler to terminate if the query has no answer set.void __fastcall TForm1::Button1Click(TObject *Sender){ if (Query1->Active) { if (SaveDialog1->Execute()) { Table1->TableName = SaveDialog1->FileName; BatchMove1->Source = Query1; BatchMove1->Destination = Table1; BatchMove1->Mode = batCopy; BatchMove1->Execute(); ShowMessage(IntToStr(BatchMove1->MovedCount) + " records copied"); } } }
The following example uses a batch move component to move the contents of a query to the table chosen from a save dialog. The Exit procedure allows the event handler to terminate if the query has no answer set.procedure TForm1.Button1Click(Sender: TObject);begin if Query1.Active = False then Exit; if SaveDialog1.Execute then begin Table1.TableName := SaveDialog1.FileName; with BatchMove1 do begin Source := Query1; Destination := Table1; Mode := batCopy; Execute; ShowMessage(IntToStr(MovedCount) + ' records copied'); end; end;
Mode := batAppend;
AbortOnKeyViol := False;
Execute;
StatusBar1.SimpleText := IntToStr(MovedCount - KeyViolCount) + ' records added';end;
if (Query1->Active)
{
if (SaveDialog1->Execute())
{
Table1->TableName = SaveDialog1->FileName;
BatchMove1->Source = Query1;
BatchMove1->Destination = Table1;
BatchMove1->Mode = batCopy;
BatchMove1->Execute();
ShowMessage(IntToStr(BatchMove1->MovedCount) + " records copied");
}
}
}
if Query1.Active = False then
Exit;
if SaveDialog1.Execute then
begin
Table1.TableName := SaveDialog1.FileName;
with BatchMove1 do
begin
Source := Query1;
Destination := Table1;
Mode := batCopy;
Execute;
ShowMessage(IntToStr(MovedCount) + ' records copied');
end;
end;