Problem loading from blob field

General TRichView support forum. Please post your questions here
Post Reply
LateralLeap
Posts: 1
Joined: Tue Dec 06, 2005 10:53 am

Problem loading from blob field

Post 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
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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)
Guest

Problem solved

Post 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);
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

LoadFromStream autodetects the stream format.
Post Reply