unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, NxControls6, NxCustomGrid6, NxVirtualGrid6, NxDBGrid6, StdCtrls,
  NxColumns6, NxDBColumns6, NxGridView6, DB, DBClient, Jpeg;

type
  TForm1 = class(TForm)
    Button1: TButton;
    NextDBGrid61: TNextDBGrid6;
    DataSource1: TDataSource;
    ClientDataSet1: TClientDataSet;
    ClientDataSet1Person: TStringField;
    ClientDataSet1Icon: TGraphicField;
    NxReportGridView61: TNxReportGridView6;
    NxDBTextColumn61: TNxDBTextColumn6;
    NxDBGraphicColumn61: TNxDBGraphicColumn6;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    procedure LoadIcon(const FileName: string);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.LoadIcon(const FileName: string);
var
  Stream: TStream;
  Jpg: TJpegImage;
begin
  Jpg := TJpegImage.Create;
  try
    Jpg.LoadFromFile(FileName);
    Stream := ClientDataSet1.CreateBlobStream(ClientDataSet1.FieldByName('ICON'), bmWrite);
    try
      Jpg.SaveToStream(Stream);
    finally
      Stream.Free;
    end;
  finally
    Jpg.Free;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
  Dialog: TOpenDialog;
begin
  ClientDataSet1.Append;
  Dialog := TOpenDialog.Create(Self);
  if Dialog.Execute then LoadIcon(Dialog.FileName);
  Dialog.Free;
  ClientDataSet1.Post;
end;

end.
