Page 1 of 1

Problem loading from blob field

Posted: Tue Dec 06, 2005 10:57 am
by LateralLeap
I have been using TDBRichView without problems

I now need to load a TRichView component from same blob field that I have been using with TDBRichView

The code I am using is as follows:
try
BlobStream := MyQuery.CreateBlobStream(MyQuery.FindField('SummaryDescription'), bmRead);
txtSummaryDescription.LoadTextFromStream(BlobStream, 0, 0, False);
txtSummaryDescription.Format;
except
end;
FreeAndNil(BlobStream);

I get rubbish in the control even though the content is same as I was loading with TDBRichView

I have an RVStyle compoennt associated with the TRichView component

The content was originally created in MS Word and pasted into the TDBRichView component

Posted: Tue Dec 06, 2005 12:52 pm
by Sergey Tkachenko
LoadTextFromStream loads plain text, but the most probably document in the field is not saved as a text, it is in RVF or RTF format (default is RVF, see FieldFormat property).

So use LoadRVFFromStream, or universal method LoadFromStream (it autodetects format of the stream data)

Problem solved

Posted: Tue Dec 06, 2005 12:53 pm
by Guest
For some reason the following code works but not sure why my original code did not.

try
BlobStream := TMemoryStream.Create;
TBlobField(MyQuery.FindField('SummaryDescription')).SaveToStream(BlobStream);
BlobStream.Position := 0;
txtSummaryDescription.LoadFromStream(BlobStream, rvynaNo);
txtSummaryDescription.Format;
except
end;
FreeAndNil(BlobStream);

Posted: Tue Dec 06, 2005 12:54 pm
by Sergey Tkachenko
LoadFromStream autodetects the stream format.