TStreams & TFields (LazDataDesktop generated code from Firebird Database) lazarus / 16-Databases ---------------------------------------------------------------------- MattStrat · 2015-02-20 14:32 Hi All, I am pretty new to Lazarus & FreePascal. I've been trying it out over the last week & have some class code generated with the LazdataDesktop tool that I am getting issues with. The tool generates 3 classes based on a database table: 1) the "Object", 2) the "Object Field Map", and 3) the "Object List" along with their code to load up from datasets, or load the objects up from their "Object Field Map" . I've got 2 areas (code generating a TStream property for a Blob field in the firebird table)  that maybe someone can help me out with (some sample code below with a test object I have called "Spec"): 1) In the main Object constructor, code generated is: Code: [Select]//code as generated by DataDesktop Tool Constructor TMySpec.Create; begin   FSPECDATA:=.Create; //error here FSPECDATA is private var for a TStream end;  I get an error illegal expression for the above... So I changed it to the following and it will compile: Code: [Select]//code altered by me Constructor TMySpec.Create; begin   FSPECDATA:=TStream.Create; //no error?? not sure if ok? end; 2) In the code below for the "Object Field Map" in its "DoLoad", I'm getting a "error-no member SaveToStream" for the FSPECDATA TField  : Code: [Select] Self.FSPECDATA.SaveToStream(SPECDATA); //error here - .SaveToStream  looks to be method of a TBlobField? More code: Code: [Select]{ TMySpecMap }   TMySpecMap = Class(TFieldMap)   Private     FSPECCODE : TField;     FSPECDATA : TField; //is a Blob in Firebird, TStream in MySpec Object     FSPECNAME : TField;     Procedure DoLoad(AObject : TMySpec);   Public     Procedure InitFields; Override;     Procedure LoadObject(AObject : TObject); Override;   end; Code: [Select]Implementation { TMySpecMap } Procedure TMySpecMap.DoLoad(AObject : TMySpec); begin   With AObject do     begin     SPECCODE:=GetFromField(Self.FSPECCODE,SPECCODE);     Self.FSPECDATA.SaveToStream(SPECDATA); //error here - .SaveToStream  looks to be method of a TBlobField?     SPECNAME:=GetFromField(Self.FSPECNAME,SPECNAME);     end; end; Can someone let me know proper way to copy my TField (FSPECDATA) data to the TStream (SPECDATA) property in the above code? The ".SaveToStream" is not a member of TField (though it is a member of TBlobField I found when searching around)? Or if there is a better place to ask this please let me know. I've attached the full unit code zip if that helps. Thanks! ---------------------------------------------------------------------- balazsszekely · 2015-02-20 15:57 Let's say you have a Blob field named GENERIC_BLOB. This is how you can read it to stream(or vice versa). uses db; var   st: TStream; begin   st := qTest.CreateBlobStream(qTest.FieldByName('GENERIC_BLOB'),  bmRead); //or bmWrite end; Where qTest is the dataset: TSQLQuery, TIBOQuery, TIBOTable, etc... Please note: This may not work, with zeos component(TZTable, TZQuery). A few days ago, a user had some issues with zeos and createblobstream.