Mega Code Archive

 
Categories / Delphi / ADO Database
 

How to append a copy of the current record

Title: How to append a copy of the current record Question: Answer: Will append an exact copy of the current record of the dataset procedure AppendCurrent(Dataset:Tdataset); var aField : Variant ; i : Integer ; begin // create a variant Array aField := VarArrayCreate([0,DataSet.Fieldcount-1],VarVariant); // read values into the array for i := 0 to (DataSet.Fieldcount-1) do aField[i] := DataSet.fields[i].Value ; DataSet.Append ; // put array values into new the record for i := 0 to (DataSet.Fieldcount-1) do DataSet.fields[i].Value := aField[i] ; end;