Page 1 of 1

TDBRichEdit Conversion Error

Posted: Tue 14 May 2013 10:32
by craigtimms
I update a TWideMemo field by streaming using a TStringStream from a TRichEdit. Occasionally it works fine.

Usually it fails on the table.Post with a EUniError: Requested conversion is not supported

Parameter[0]: ACT_NOTES - invalid Value (Status = 2h)

Plain text always works....if I change the font colour or make it bold then *BAM* it bombs

Not clever.

Can anyone help me please

Here's the streaming code, which debugs fine, code falls over on the post:

procedure Tdm.StreamRE2WM(Source: TRichEdit; Target: TWideMemoField);
var
ss : TStringStream;
begin
ss := TStringStream.Create;
Source.Lines.SaveToStream(ss);
ss.Position := 0;
Target.LoadFromStream(ss);
FreeAndNil(ss);
end;

Re: TDBRichEdit Conversion Error

Posted: Tue 14 May 2013 15:58
by AndreyZ
To solve the problem, you should create TStringStream with the correct encoding. Here is a code example:

Code: Select all

procedure Tdm.StreamRE2WM(Source: TRichEdit; Target: TWideMemoField);
var
  ss: TStringStream;
begin
  ss := TStringStream.Create(Source.Lines.Text, TEncoding.Unicode);
  try
    ss.Position := 0;
    Target.LoadFromStream(ss);
  finally
    ss.Free;
  end;
end;
For more information about the correct usage of TRichEdit and TWideMemoField, please write to the Embarcadero support.

Re: TDBRichEdit Conversion Error

Posted: Tue 14 May 2013 17:09
by craigtimms
The UniError disappears but the Richedit loses all it's formatting

Re: TDBRichEdit Conversion Error

Posted: Thu 16 May 2013 11:59
by AndreyZ
We do not develop TDBRichEdit, so this question is out of scope of our support. Please write about this problem to the Embarcadero support.