Mega Code Archive

 
Categories / Delphi / ADO Database
 

Save RTF in a TBlobfield

Title: Save RTF in a TBlobfield Question: Unfortunately there is no TDBRichEdit control. How can this be solved ? Answer: In this example the field 'Table1Memo' is a paradox 'formatted memo'. It also could be a blob field. Via TBlobStream the content of the RichEdit control an be loaded from the database or saved: procedure TForm1.BtnGetClick(Sender: TObject); var bs: TBlobStream; begin bs:= Nil; with Table1 Do try open; first; bs:= TBlobStream.Create( table1memo, bmread ); Richedit1.plaintext := false; Richedit1.Lines.Loadfromstream(bs); finally bs.free; close; end; end; procedure TForm1.BtnPutClick(Sender: TObject); var bs: TBlobStream; begin bs:= Nil; with Table1 Do try open; first; edit; bs:= TBlobStream.Create( table1memo, bmwrite ); Richedit1.plaintext := false; Richedit1.Lines.Savetostream(bs); post; finally bs.free; close; end; end;