Page 1 of 1

Saving RichViewEdit content in BLOB field using BDE

Posted: Thu Nov 05, 2009 4:48 pm
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 ?

Posted: Thu Nov 05, 2009 7:45 pm
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.

Posted: Thu Nov 05, 2009 8:42 pm
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.

Posted: Sat Nov 07, 2009 11:46 am
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.

Posted: Mon Nov 09, 2009 10:17 am
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 ?

Posted: Mon Nov 09, 2009 10:53 am
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)