Question on saving to DB Field
Posted: Wed Dec 08, 2010 4:37 pm
I'm a new user of TRichView and I have now a problem, as I don't konw what is wrong.
I have a TDBRichView connected to a DB Field and an external TRichViewEdit to edit the content of that field. The TDBRichView is only used to display the content of the DB field.
I pass the db field content like this to my editor:
For saving the edited content of the TRichViewEdit back to the DB Field I use this code:
On the calling form I do this then:
MyTableRVSource.AsString := frmHTMLEditor.RVSource;
MyTable.Post;
Now the problem ist, that this doesnt work and the resulting db Field content isn't the same as if I save the content of the RichViewEdit to an external File. The DBRichView diaplays only unreadable chars and no RichView formated text.
it looks like this in TDBRichView:
Saving the content to an external file with TRichViewEdit.SaveRVF results in a file size of 79'065 bytes, while the content of SaveRVFToStream results only in 69'705 bytes. Why?
Any idea what I'm doing wrong? [/code]
I have a TDBRichView connected to a DB Field and an external TRichViewEdit to edit the content of that field. The TDBRichView is only used to display the content of the DB field.
I pass the db field content like this to my editor:
Code: Select all
// MyTableRVSource is a blob field
frmHTMLEditor.RVSource := MyTableRVSource.AsString;
This is the RVSource property set procedure:
procedure TfrmHTMLEditor.SetRVSource(const Value: String);
var
Stream: TStringStream;
begin
if Value <> '' then
begin
Stream := TStringStream.Create(Value);
try
Stream.Position := 0;
RichViewEdit.LoadRVFFromStream(Stream);
RichViewEdit.Format;
finally
Stream.Free;
end;
end;
end;
Code: Select all
function TfrmHTMLEditor.GetRVSource: String;
var
Stream: TStringStream;
begin
(* This works, but I don't want do create a file!
RichViewEdit.SaveRVF('d:\test.rvf', False);
Stream := TFileStream.Create('d:\test.rvf', fmOpenRead or fmShareDenyNone);
try
SetLength(Result, Stream.Size);
Stream.ReadBuffer(Pointer(Result)^, Stream.Size);
finally
Stream.Free;
end;
*)
Stream := TStringStream.Create('');
try
RichViewEdit.SaveRVFToStream(Stream, False);
Stream.Position := 0;
Result := Stream.DataString;
finally
Stream.Free;
end;
end;
MyTableRVSource.AsString := frmHTMLEditor.RVSource;
MyTable.Post;
Now the problem ist, that this doesnt work and the resulting db Field content isn't the same as if I save the content of the RichViewEdit to an external File. The DBRichView diaplays only unreadable chars and no RichView formated text.
it looks like this in TDBRichView:
Code: Select all
-8 1 3
-7 0 -1 0 0 0 0 536870911
-9 2 0 0 2 0 1
RVStyle
........
Saving the content to an external file with TRichViewEdit.SaveRVF results in a file size of 79'065 bytes, while the content of SaveRVFToStream results only in 69'705 bytes. Why?
Any idea what I'm doing wrong? [/code]