TDBRichEdit Conversion Error

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
craigtimms
Posts: 3
Joined: Tue 23 Apr 2013 17:26

TDBRichEdit Conversion Error

Post by craigtimms » Tue 14 May 2013 10:32

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;

AndreyZ

Re: TDBRichEdit Conversion Error

Post by AndreyZ » Tue 14 May 2013 15:58

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.

craigtimms
Posts: 3
Joined: Tue 23 Apr 2013 17:26

Re: TDBRichEdit Conversion Error

Post by craigtimms » Tue 14 May 2013 17:09

The UniError disappears but the Richedit loses all it's formatting

AndreyZ

Re: TDBRichEdit Conversion Error

Post by AndreyZ » Thu 16 May 2013 11:59

We do not develop TDBRichEdit, so this question is out of scope of our support. Please write about this problem to the Embarcadero support.

Post Reply