Author: Tomas Rutkauskas
How would I store an OLE object into a database's blob field and preferably be able
to read it back in a usable form later on?
Answer:
To write a TOLEContainer to a blobfield:
1 var2 Stream: TBlobStream;
3 begin4 Stream := TBlobStream.Create(myOleField, bmWrite);
5 try6 Ole1.SaveToStream(Stream);
7 finally8 Stream.Free;
9 end;
10 end;
11 12 //To read it back:13 14 var15 Stream: TBlobStream;
16 begin17 Stream := TBlobStream.Create(BugData.NotesNote, bmRead);
18 try19 Ole1.LoadFromStream(Stream);
20 Ole1.Iconic := False;
21 finally22 Stream.Free;
23 end;
24 end;
Where you put the code is up to you, but the DataChange and UpdateData events of the appropriate TDatasource might be a good idea.