Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   hay algun comando para duplicar una ficha de un memtable? (https://www.clubdelphi.com/foros/showthread.php?t=65493)

cocute 19-12-2009 12:06:23

hay algun comando para duplicar una ficha de una tkbmemtable?
 
hay algun comando para duplicar una ficha de una Tkbmemtable?
con table1.insert añado
con table2.delete borro
existe algun comando tipo table1.duplicate para duplicar la ficha seleccionada
¿o tengo que hacerlo a mano?

he encontrado esta funcion pero no me funciona bien, no se porque me quedan campos sin copiar, uso delphi 2010.

Código PHP:

procedure DuplicateCurrentRecord(aDataSet TDataSet); 
var 
  
Data : array of variant
  
aRecord : array of TVarRec
  
integer
  
max integer
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 := 0 to max do 
  
begin 
    arecord
[i].VType := vtVariant
    
arecord[i].VVariant := @data[i]; 
  
end

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

  
// finally append the record in one go 
  
aDataSet.AppendRecord(aRecord); 
end

lo he pasado para que funcione con kbmemtable pero como digo no me duplica todos los campos de las fichas,
los demas los deja en blanco, es raro porque a veces me duplica los dos primeros, otras veces los tres primeros....

Código PHP:

procedure DuplicateCurrentRecord(aDataSet TkbmMemTable);

 var
  
Data : array of variant;
  
aRecord : array of TVarRec;
  
integer;
  
max integer;
begin
  max 
:= aDataSet.RecordCount -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 := 0 to max do
  
begin
    arecord
[i].VType := vtVariant;
    
arecord[i].VVariant := @data[i];
  
end;

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

  
// finally append the record in one go
  
aDataSet.AppendRecord(aRecord);
end



La franja horaria es GMT +2. Ahora son las 21:14:01.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi