Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Copiar registros en RXMemoryData (https://www.clubdelphi.com/foros/showthread.php?t=58703)

Carmelo Cash 29-07-2008 15:14:05

Copiar registros en RXMemoryData
 
Hola Foro:

Necesito pasar algunos campos de un RXMemoryData a otro, para hacer esto hago un loop y guardo campo por campo.
quería saber si es posible No pasar campo por campo, solamente para que quede más prolijo. gracias.

Adjunto el código que estoy utilizando.



procedure TEdiniFrm.SeleccionarSeccion;
begin
RxMDSecciones.Active:=True;
RxMDSecciones.EmptyTable;
with RxMDCompleto do begin
first;
while not eof do begin
if RxMDCompleto.FieldByName('Tipo').AsInteger=1 then begin
RxMDSecciones.Append;
RxMDSecciones.FieldByName('ID_INI').AsInteger:= RxMDCompleto.FieldByName('ID_INI').AsInteger;
RxMDSecciones.FieldByName('ID_Seccion').AsInteger:= RxMDCompleto.FieldByName('ID_Seccion').AsInteger;
RxMDSecciones.FieldByName('Orden_Seccion').AsInteger:= RxMDCompleto.FieldByName('Orden_Seccion').AsInteger;
RxMDSecciones.FieldByName('Orden_Item').AsInteger:= RxMDCompleto.FieldByName('Orden_Item').AsInteger;
RxMDSecciones.FieldByName('Tipo').AsInteger:= RxMDCompleto.FieldByName('Tipo').AsInteger;
RxMDSecciones.FieldByName('Campo').AsString:= RxMDCompleto.FieldByName('Campo').AsString;
RxMDSecciones.FieldByName('Valor').AsString:= RxMDCompleto.FieldByName('Valor').AsString;
RxMDSecciones.FieldByName('Comentario').value:= RxMDCompleto.FieldByName('Comentario').value;
RxMDSecciones.Post;
end;
next;
end; // while
end; // with
end;

Neftali [Germán.Estévez] 29-07-2008 16:10:33

91 mensajes y seguimos así con los TAG's...:(

Neftali [Germán.Estévez] 29-07-2008 16:16:32

Cita:

Empezado por Carmelo Cash (Mensaje 304098)
para hacer esto hago un loop y guardo campo por campo.
quería saber si es posible No pasar campo por campo


Puedes buscar si RxMDSecciones posee algun método tipo Assign o Clone.
La otra opción es recorrer los fields con un blucle FOR en lugar de uno a uno utilizanfo la propiedad Fields (y un índice) en lugar de FieldByName.

Carmelo Cash 29-07-2008 17:25:31

Gracias
 
Gracias Neftali, quedó así, y aprendí a usar los Tags.

Hay algo como los Tags para el código en el programa?
(please no me verdugueen):)

Código Delphi [-]
procedure  TEdiniFrm.CargarSecciones;
var
i:Integer;
begin
  RxMDSecciones.Active:=True;
  RxMDSecciones.EmptyTable;
  with RxMDCompleto do begin
    first;
    while not eof do begin
      if RxMDCompleto.FieldByName('Tipo').AsInteger=1 then begin
        RxMDSecciones.Append;
        for i := 0 to RxMDCompleto.FieldCount - 1 do begin
          RxMDSecciones.Fields[i].Value:= RxMDCompleto.Fields[i].Value;
        end;
        RxMDSecciones.Post;
      end;
      next;
    end;    // while
  end;    // with
 RxMDSecciones.SortOnFields('Orden_Seccion');
end;

Neftali [Germán.Estévez] 29-07-2008 17:29:18

Ahora te quedaron perfectas.... Ambas cosas ;)


La franja horaria es GMT +2. Ahora son las 03:33:47.

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