RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TBlobField.LoadFromStream Method

Loads BLOB data from a stream into the field.

Pascal
procedure LoadFromStream(Stream: TStream);
C++
__fastcall LoadFromStream(TStream Stream);

Use LoadFromStream to copy the contents of a stream into the BLOB field. Specify the stream from which the field's value is copied as the value of the Stream parameter.

Note: The Stream parameter is typically not a BLOB stream. BLOB streams (returned by the dataset's CreateBlobStream method) provide a completely separate mechanism for streaming data into a BLOB field.

var
  MS: TMemoryStream;
begin
if not (ClientDataSet1.State in [dsInsert, dsEdit]) then
 ClientDataSet1.Insert;
  MS := TMemoryStream.Create();
try
Image1.Picture.Bitmap.SaveToStream(MS);
    ClientDataSet1Images.LoadFromStream(MS);
finally
    MS.Free;
end;
  ClientDataSet1.Post;
end;

 

if ((ClientDataSet1->State != dsInsert) &&
(ClientDataSet1->State != dsEdit))
  ClientDataSet1->Insert();
TMemoryStream *pMS = new TMemoryStream;
try
{
  Image1->Picture->Bitmap->SaveToStream(pMS);
  ClientDataSet1Images->LoadFromStream(pMS);
}
__finally
{
delete pMS;
}
ClientDataSet1->Post();

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!