TTMSFMXRichEditor - Help LoadFrom Stream

Here is a code snippet and I'm getting a EReadError with message 'Stream read error'. I've already saved the field DM.tblSignaturessignature_rich as a BLOB with the following code. The code snippet for the Load routine is giving me the EReadError message. I've tried every combination that I can think of - does anyone have any suggestions how to load the RTE data from the database?


Thanks,
Mike

**** Original Save TMSFMSRichEdit code

var
  SqlStmt: string;
  sq: TSQLQuery;
  StrStream: TStringStream;
  s: string;

begin
                  StrStream := TStringStream.Create(s);
                  SignatureEditor.SaveToStream(StrStream);
                  StrStream.Position := 0;
                  sq := TSQLQuery.Create(nil);
                  sq.SQLConnection := DM.CnnSettings;
                  sq.SQL.Text := 'UPDATE tblSignatures SET signature_name = :SigName, signature_body = :SigBody, signature_rich = :SigRich WHERE id = :SigId';
                  sq.Params.ParseSQL(sq.SQL.Text, true);
                  sq.Params.ParamByName('SigName').AsString := txtSignatureName.Text.Trim;
                  sq.Params.ParamByName('SigBody').AsString := ReturnSignatureHTML;
                  sq.Params.ParamByName('SigRich').LoadFromStream(StrStream, ftBlob);
                  sq.Params.ParamByName('SigId').AsInteger := SignatureId;
  sq.ExecSQL();

***** Load  TMSFMXRichEdit Code
var
  StrStream: TStringStream;
  s: string;
begin
      StrStream := TStringStream.Create(s);
      StrStream.SetSize(Length(DM.tblSignaturessignature_rich.AsString));
      StrStream.WriteBuffer(DM.tblSignaturessignature_rich.AsBytes, Length(DM.tblSignaturessignature_rich.AsString));
      StrStream.Position := 0;
      SignatureEditor.LoadFromStream(StrStream);

Tested with Bytesstream, works ok with FireDAC
1. Use BytesStream instead of StringStream in your example
2. Check your DB Column Type (use bytea for example in postgres)
What DB are you using anyway? Would help alot in your example.

Cheers.

Zolow,


Thanks for the reply. I will give that a try. I'm using SQLite and the column is defined as a BLOB.

Regards,
Mike