Page 1 of 1

DB Access + TRichView

Posted: Mon Jan 01, 2007 6:58 pm
by asteblev
Hi, Sergey. Her is the problem. I use Access to save the RVF files. I`ve a field of type MEMO. But when I load a data from this fiel nothing is going on. Her is the code:

To Save:
main.bufer.SQL.Text := 'update documents set content="" where id_doc=1' ;
main.bufer.ExecSQL ;
ADOTable1.TableName := 'documents' ;
ADOTable1.Open ;
ADOTable1.First ;
ADOTable1.Edit ;
Stream := ADOTable1.CreateBlobStream(ADOTable1.FieldByName('content'), bmWrite);
try
RichViewEdit1.SaveRVFToStream(Stream, false);
finally
Stream.Free;
end;
ADOTable1.Post;


To Load:
ADOTable1.TableName := 'documents' ;
ADOTable1.Open ;
ADOTable1.First ;
Stream := ADOTable1.CreateBlobStream(ADOTable1.FieldByName('content'), bmRead);
try
RichView1.LoadRTFFromStream(Stream);
RichView1.Format;
finally
Stream.Free;
end;

Posted: Mon Jan 01, 2007 7:22 pm
by Sergey Tkachenko
Copy content of the field to file and send to me

Code: Select all

ADOTable1.TableName := 'documents' ; 
ADOTable1.Open ; 
ADOTable1.First ; 
Stream := ADOTable1.CreateBlobStream(ADOTable1.FieldByName('content'), bmRead); 
try 
  FileStream := TFileStream.Create('c:\problem.rvf', fmCreate);
  FileStream.CopyFrom(Stream, 0);
  FileStream.Free;
finally 
  Stream.Free; 
end;

Posted: Mon Jan 01, 2007 7:35 pm
by Sergey Tkachenko
Possible reasons:
1) Memo field cannot contain binary data (the document is corrupted)
Solution: select another field type, or exclude rvfoSaveBinary from RichViewEdit1.RVFOptions
2) Styles are not saved with documents (document can be loaded only of RichViewEdit1.Style has the same collections of styles as they were on saving)
Solution: right click RichViewEdit1 in Delphi, choose "Settings", select "Allow adding styles dynamically". Make sure that no other RichView uses the same RVStyle component as RichViewEdit1.

Posted: Tue Jan 02, 2007 11:26 am
by asteblev
Yes, Sergey, u are right, that field MEMO is wrong. The type must to be OLE. but when I load the data, richview show the text-style and text without formating.

Posted: Tue Jan 02, 2007 11:38 am
by Sergey Tkachenko
May be you included rvfoConvUnknownStylesToZero in RichViewEdit1.RVFOptions?
If yes, RVF documents with mismatched styles will be loaded, but all unknown styles (with too large index) will be converted to 0.

Posted: Tue Jan 02, 2007 4:25 pm
by asteblev
Great thank you, Sergey. All is ok.