DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Copy the current record of a dataset

I found this routine which copies the current record of the currently selected record. This is useful e.g. to keep a temporary record for display in a form.


 {************************************************
 // procedure AppendCurrent
 //
 // Written By: Steve Zimmelman
 // 6/4/96
 //
 // Version: Delphi 2.0
 //
 // Will append an exact copy of the current
 // record of the dataset that is passed into
 // the procedure and will return the dataset
 // in edit state with the record pointer on
 // the currently appended record.
 ************************************************}
 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
   begin
      aField[i] := DataSet.fields[i].Value ;
   end;
   DataSet.Append ;
   // Put array values into new the record
   for i := 0 to (DataSet.Fieldcount-1) do
   begin
      DataSet.fields[i].Value := aField[i] ;
   end;
 end;
 

Generated 8:01:31 on Nov 19, 2017