Subject | Re: [IBO] TIBOQuery.TBlobField - Saving to Stream |
---|---|
Author | Helen Borrie |
Post date | 2007-09-17T22:44:11Z |
At 02:11 AM 18/09/2007, you wrote:
it, to which the stream's contents could be assigned, but your
procedure does not do anything with the stream after filling its
buffer. It is just a local memory buffer that is not associated with
anything, e.g., a compatible TGraphic, TMemo, or whatever member
object inside the structure.
I won't attempt to guess what's intended here, but one supposes that
your FDefinitions.Clear method actually stores the current contents
of its member buffers somewhere before clearing them. Otherwise, it
seems a bit pointless to loop through a dataset doing all this work
on every record, if the ultimate objective is to fill the structure
with the data from the last record.
Helen
>Hello all.Supposedly your FDefinitions structure has a compatible class within
>Well i have another problem with blob fields. :-(
>I have a procedure that uses a dataset (a TIBOQuery), finds the
>blobfield by name and saves it to a stream, or so i thought! I realy
>dont know why but the TBlobField.SaveToStream(TMemoryStream) does
>nothing. But if instead i use TBlobField.SaveToFile('c:\file.txt') it
>works perfectly.
>
>Here's the code:
>
>procedure TUser.LoadDefs;
>var
> i: integer;
> ms: TMemoryStream;
>begin
> // FDefsDataSet is a TDataSet from the User class. When the user
> // class is initiated the FDefsDataSet field has its value assigned
> // to a TIBOQuery.
>
> if (FDefsDataSet.RecordCount = 0) then Exit;
>
> FDefsDataSet.First;
> ms := TMemoryStream.Create;
> for i := 0 to (FDefsDataSet.RecordCount-1) do
> begin
> FDefinitions.Clear;
> with FDefinitions.Add do
> begin
> FClassName := FDefsDataSet.FieldByName('CLASS').AsString;
> (FDefsDataSet.FieldByName('DEF') as TBlobField).SaveToStream
>(ms);
> FUserData := FDefsDataSet.FieldByName('AUDIT_DATA').AsDateTime;
> FUserDsc := FDefsDataSet.FieldByName('AUDIT_USER_DSC').AsString;
> end;
> FDefsDataSet.Next;
> end;
>end;
>
>Any help on this matter would be mutch appreciated!
it, to which the stream's contents could be assigned, but your
procedure does not do anything with the stream after filling its
buffer. It is just a local memory buffer that is not associated with
anything, e.g., a compatible TGraphic, TMemo, or whatever member
object inside the structure.
I won't attempt to guess what's intended here, but one supposes that
your FDefinitions.Clear method actually stores the current contents
of its member buffers somewhere before clearing them. Otherwise, it
seems a bit pointless to loop through a dataset doing all this work
on every record, if the ultimate objective is to fill the structure
with the data from the last record.
Helen