Einzelnen Beitrag anzeigen

jensw_2000
(Gast)

n/a Beiträge
 
#2

Re: ClientDataset-Datensätze kopieren

  Alt 3. Jun 2005, 00:40
Dazu kannst das dir folgenden Codelib Eintrag "verbiegen"

[cl]aktuellen Datensatz kopieren/duplizieren[/cl]

Delphi-Quellcode:
procedure CopyCurrentRecord(Quelltabelle, Zieltabelle : TDataSet);
var
  Data : array of variant;
  aRecord : array of TVarRec;
  i : integer;
  max : integer;
begin

  Quelltabelle.first;

  While not Quelltabelle.eof do
  begin

    max := aDataSet.fields.count -1;
    // set the lenghth of the arecord array to be the same as the number of
    // elements in the data array
    SetLength(arecord,max+1);
    SetLength(data,max+1);

    // set the variant type pointers to the data array
    for i := 0 to max do
    begin
      arecord[i].VType := vtVariant;
      arecord[i].VVariant := @data[i];
    end;

    // Copy the Record to the Array
    for i := 0 to max do
      Data[i] := Quelltabelle.fields[i].value;

    // hier muss ggf noch etwas geschraubt werden, falls du berechnete- bzw. Autoinc Felder verwendest
    Zieltabelle.Appendrecord(aRecord);
    
    // fertig, nächster Datensatz ..
    Quelltabelle.next;

  end; // While

end;
  Mit Zitat antworten Zitat