Board index » delphi » Saving OLE info to BLOB Field

Saving OLE info to BLOB Field

Hi,

I have an application that needs to view/edit floorplan images and then
store that image in a database.  I want to use OLE to accomplish this to
allow the user to choose what application to use for the image creation and
editing. I have created a form to add/edit records in FloorPlan table and
added a TOleContainer component.  At this point I want the user to be able
to create/load the floorplan image using whatever application suits them and
then save it in a blob field in the FloorPlan table.

Is this possible and if so how?

TIA,

Steve
smitc...@profitsys.sk.ca

 

Re:Saving OLE info to BLOB Field


In article <7pjp22$7s...@forums.borland.com>, smitc...@profitsys.sk.ca

Quote
(Steve Mitchell) wrote:
> added a TOleContainer component.  At this point I want the user to be
> able
> to create/load the floorplan image using whatever application suits
> them and
> then save it in a blob field in the FloorPlan table.

> Is this possible and if so how?

Yes, it is possible, you need to use the LoadFromStream and SaveToStream
methods of the TOleContainer.

For example:

var
  MyStream: TBLOBStream;
  MyBlob: TBlobField;
begin
  Table1.edit;
  MyBlob := Table1.FieldByName('CLientCV') as TBlobField;
  MyStream := Tblobstream.create(MyBlob, bmreadwrite);
  ctrOLE.savetostream(MyStream);
  MyStream.Free;
  Table1.post;
end;

and:

var
  MyStream: TBLOBStream;
  MyBlob: TBlobField;
begin
  MyBlob := Table1.FieldByName('CLientCV') as TBlobField;
  MyStream := Tblobstream.create(MyBlob, bmread);
  ctrOLE.LoadFromstream(MyStream);
  ctrOLE.DoVerb(ovPrimary);
  MyStream.Free;
end;

Other Threads