Ver Mensaje Individual
  #6  
Antiguo 27-09-2011
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Paulao.

Concretamente, ¿ Que buscas hacer con el ClientDataSet en memoria ?, ¿ Que es lo que no podés lograr ?

Supongamos que creaste los campos:
Código:
ID     : Integer;
Codigo : sring;
Fecha  : tDate
Numero : Integer;
y los cargas así:
Código Delphi [-]
procedure TForm1.FormShow(Sender: TObject);
var
  i: Integer;
begin
  Randomize;
  with CDS do
  begin
    CreateDataSet;
    Open;
    for i:= 1 to 1000 do
    begin
      Append;
      FieldByName('ID').AsInteger := i;
      FieldByName('Codigo').AsString := 'Cod'+
        StringOfChar('0',4-Length(IntToStr(1000-i)))+ IntToStr(1000-i);
      FieldByName('Fecha').AsDateTime := Date();
      FieldByName('Numero').AsFloat := Random(10000);
      Post;
    end;
    First;
  end;
end;

Te pongo algunos ejemplos simples de acciones que podés hacer con un TClientDataSet en memoria:

Seleccionar el índice:
Código Delphi [-]
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  with CDS do
  begin
    Close;
    case RadioGroup1.ItemIndex of
      0: CDS.IndexFieldNames:= 'ID';
      1: CDS.IndexFieldNames:= 'Codigo';
      2: CDS.IndexFieldNames:= 'Fecha';
      3: CDS.IndexFieldNames:= 'Numero';
    end;
    Open;
  end;
end;

Obtener los nombres y valores de los campos:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  for i:= 0 to CDS.FieldCount -1 do
    ListBox1.Items.Add(CDS.Fields[i].FieldName+': '+CDS.Fields[i].AsString);
end;

Buscar un campo:
Código Delphi [-]
function Buscar(ACDS: TClientDataSet; Campo: string; Dato: Variant): Boolean;
begin
  CDS.Locate(Campo, Dato,[]);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Buscar(CDS,'ID', 990);
  if Buscar(CDS,'Codigo','Cod0091') then
  ...
end;
...

Y la lista sigue...

Sería más fácil resolver tu inquietud si nos contás en que radica tu dificultad

Un saludo.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita