Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to save formatted Rich Text (RTF) to Blob field, and retrieve from BLOB field

1,134 views
Skip to first unread message

ching chua tee

unread,
Jul 28, 2005, 11:43:38 PM7/28/05
to
I need some help !!

I have one field as BLOB file type, Size = 80, subtype = 4 (means i want to
save as RTF format) in my table. The problem is that when i pass my
formatted text (eb. Bold, Underline etc) to save into the BLOB field, then i
retrieve back from the BOLD content, it appear text without any format. I
need to
retrieve 'FORMATTED' text back to my RichText control. for me to print
report.

I'm using Delphi 5....database is Interbase database.


Dave Albiston

unread,
Jul 29, 2005, 3:58:21 AM7/29/05
to
I've only done this when saving the text to a VARCHAR column. To save
the contents of a TRichEdit control I used the following code:

var
MemStr: TMemoryStream;
begin
MemStr := TMemoryStream.Create;
try
RTFEdit.Lines.SaveToStream(MemStr);
Dataset.FieldByName(FieldName).AsString := PChar(MemStr.Memory)
finally
FreeAndNil(MemStr)
end
end;

To populate the control with saved data I used:

var
MemStr: TMemoryStream;
begin
MemStr := TMemoryStream.Create;
try
MemStr.Write(Dataset.FieldByName(FieldName).AsString[1],
length(Dataset.FieldByName(FieldName).AsString));
MemStr.Position := 0;
RTFEdit.Lines.LoadFromStream(MemStr);
finally
FreeAndNil(MemStr)
end
end;

HTH

Dave

0 new messages