Save richedit to mdb code example
Example: Save richedit to mdb
//Save to stream
stream := TMemoryStream.Create;
stream.Clear;
RichEdit.Lines.SaveToStream(stream);
stream.Position := 0;
//Read from the stream into an AnsiString (rtfString)
if (stream.Size > 0) then begin
SetLength(rtfString, stream.Size);
if (stream.Read(rtfString[1], stream.Size) <= 0) then
raise EStreamError.CreateFmt('End of stream reached with %d bytes left to read.', [stream.Size]);
end;
stream.Free;
//Save to database
sql.FieldByName('rtftext').AsAnsiString := rtfString;