Ver Mensaje Individual
  #2  
Antiguo 24-08-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
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.

Código Delphi [-]
procedure SaveCol(aGrid: TDBGrid; const ColNro: Integer; 
  aDataSet: TDataSet; const aFieldName: string);
var
  BM: Pointer;
  s : string;
begin
  with aGrid.DataSource.DataSet do
  begin
    DisableControls;
    BM := GetBookmark;
    try
      First;
      while not Eof do
      begin
        s := s + aGrid.Columns[ColNro].Field.AsString + ',';
        Next;
      end;
      SetLength(s,Length(s)-1);
    finally
      GotoBookmark(BM);
      FreeBookmark(BM);
      EnableControls;
    end;
  end;
  with aDataSet do
  begin
    Append;
    FieldByName(aFieldName).AsString := s;
    Post;
  end;
end;

Ejemplo de uso:
Código Delphi [-]
  // Se supone a DataSet1 abierto
  SaveCol(DBGrid1, 1, DataSet1, 'Campo');

Saludos
__________________
Daniel Didriksen

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