Scalabium Software

SMExport advertising

Knowledge for your independence.
Home Delphi and C++Builder tips



#65:How can I save/restore the component into BLOB-field?

Sometimes in applications you must save the component into BLOB-field of the own table and in run-time to restore it. For example, to save the report form and in run-time the end-user will select the wished report before report generation.

The next two procedure allows to save the component with all properties and restore it.

procedure SaveCompToBlob(AField: TBlobField; AComponent: TComponent);
var
  Stream: TBlobStream;
  CompName: string;
begin
  CompName := Copy(AComponent.ClassName, 2, 99);
  Stream := TBlobStream.Create(AField, bmWrite);
  try
    Stream.WriteComponentRes(CompName, AComponent);
  finally
    Stream.Free;
  end;
end;

procedure LoadCompFromBlob(AField: TBlobField; AComponent: TComponent);
var
  Stream: TBlobStream;
  i: integer;
begin
  try
    Stream := TBlobStream.Create(AField, bmRead);
    try
      {delete the all child components}
      for i := AComponent.ComponentCount - 1 downto 0 do
        AComponent.Components[i].Free;
      Stream.ReadComponentRes(AComponent);
    finally
      Stream.Free;
    end;
  except
    on EFOpenError do {nothing};
  end;
end;
See also
 
SMExport suite
SMImport suite
SMReport
SMDBGrid
MAPIMail
Paradox Viewer
Paradox ActiveX
ExcelFile Viewer
Metafile Convert
DBLoad
DBExport tools
 
 
Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyrightc 1998-2008, Scalabium Software. All rights reserved.
webmaster@scalabium.com

February 11, 2000

SMReport Autogenerated