RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TBlobStream.Create Constructor

Creates an instance of TBlobStream.

Pascal
constructor Create(Field: TBlobField; Mode: TBlobStreamMode);
C++
__fastcall TBlobStream(TBlobField Field, TBlobStreamMode Mode);

Call Create to obtain an instance of TBlobStream for reading from or writing to a specific TBlobField object.

Tip: Different types of dataset use different classes of BLOB streams. It is usually a better idea to call the dataset's CreateBlobStream method than to call the BLOB stream constructor.
Create links the TBlobStream to the field object specified by the Field parameter. Mode specifies whether the BLOB stream will be used to read data (bmRead), write data (bmWrite) or modify data (bmReadWrite). Mode must be one of the following values:

Value 
Meaning 
bmRead  
The BLOB stream can read data from the field.  
bmWrite  
The BLOB stream can replace the data in the field.  
bmReadWrite  
The BLOB stream can modify the data in the field.  

Note: : A TBlobStream object should always be destroyed before navigating to a new record. Create a new instance of TBlobStream for the new record.
 

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!