RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TBDEDataSet.CreateBlobStream Method

Returns a TStream object for reading or writing the data in a specified blob field.

Pascal
function CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream; override;
C++
virtual __fastcall TStream CreateBlobStream(TField Field, TBlobStreamMode Mode);

Call CreateBlobStream to obtain a stream for reading data from or writing data to a binary large object (BLOB) field. The Field parameter must specify a TBlobField component from the Fields property array. The Mode parameter specifies whether the stream will be used for reading, writing, or updating the contents of the field. 

Blob streams are created in a specific mode for a specific field on a specific record. Applications should create a new blob stream every time the record in the dataset changes rather than reusing an existing blob stream.  

Delphi Examples: 

 

{
The following example copies the data in the Notes field of
Table1 or SQLDataSet1 to the Remarks field of ClientDataSet1.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  Stream1: TBlobStream;
  Stream2: TStream;
  blobType : TBlobType;
begin
  blobType := Table1Notes.BlobType;
  Stream1 := TBlobStream.Create(Table1Notes, bmRead);
  try
    CDS2.Edit;
    { here’s a different way to create a blob stream }
    Stream2 := CDS2.CreateBlobStream(CDS2.FieldByName('Remarks'), bmReadWrite);
    try
      Stream2.CopyFrom(Stream1, Stream1.Size);
//    CDS2.Post;
//    CDS2.Active := True;
    finally
      Stream2.Free;
    end;
  finally
    Stream1.Free;
  end;
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!