Saving RichViewEdit content in BLOB field using BDE

General TRichView support forum. Please post your questions here
Post Reply
fingase
Posts: 5
Joined: Wed Nov 04, 2009 7:54 am

Saving RichViewEdit content in BLOB field using BDE

Post by fingase »

I am using C++ Builder 2009 and have problems saving RichViewEdit into the BLOB field into local paradox table.

Here is the relevant part of my code:

DataModule1->Query1->SQL->Add("INSERT INTO rvftable (id,rvfcontent) ");
DataModule1->Query1->SQL->Add(" VALUES (:id,:rvfcontent)");
DataModule1->Query1->ParamByName("id")->AsInteger = pacid;
TMemoryStream* stream = (new TMemoryStream);
RichViewEdit1->SaveRVFToStream(Stream, false);
DataModule1->Query1->Params->ParamByName("rvfconten")->SetBlobData(stream->Memory,stream->Size);
DataModule1->Query1->ExecSQL();
DataModule1->Query1->Close();
delete stream;



The result in the blob table shows only set of question marks: "????????????????????????"

When I save the stream to the file it shows something different.
Thus I have a question: How to properly save (and read) content of RichEditView using BDE TQuery (not TTable) component ?
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I never used TQuery myself...
ParamByName("rvfconten") instead of ParamByName("rvfcontent") - may be this is an error?
What is the field type for this field? It should be "BINARY", not memo.
fingase
Posts: 5
Joined: Wed Nov 04, 2009 7:54 am

Post by fingase »

rvfcontent is not an issue.

It seems the problem is with C++ Buider 2009 (unicode in BLOB?) because with version 2006 it works fine.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Probably...
What's about checking a field type? For binary types, no conversion to/from Unicode should be made, because it is not for storing text.
fingase
Posts: 5
Joined: Wed Nov 04, 2009 7:54 am

Post by fingase »

I have found the description of TParam.LoadFromStream problem in D2009:

"The problem is in db.pas unit. In older non unicode versions of delphi
LoadFromStream use string variable to read data from stream and pass them to param value. Now use TBytes to read data. If you changed TBytes with AnsiString or if you pass data to param value using StringOf(TBytes variable) it works Ok."

but it seems to me that StringOf cannot work with not string data like in RVF format. Thus how to store RVF data in blobs ?
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If, because of this bug, TParam cannot be used to assign binary data (like jpeg or rvf), all that I can suggest is using RTF instead and assign it as string.
Unfortunately, some document attributes are lost when saving to RTF.

(there is an option for saving text RVF, but it will not work correctly if the document will be converted to Unicode and back, because this text-mode RVF can contain characters from different code pages)
Post Reply