How to force the Data to appear on the DBWPRichText Comp

  • Am I missing a step to force the data referenced by the following to show up on the TDBWPRichText object?

    TDataSource ds1;
    TDBWPRichText DBRichEdit;

    ds1->DataSet = <ADO Query>;
    DBRichEdit->DataSource = ds1;
    DBRichEdit->DataField = String("<Field Name>");

    The same code still works and the Richtext retrieved is showing up as soon as the <field name> was updated in version 4.22 of the WpTools however the only way I can get RichText to show up with Wptools 6.0 is to trigger another output event (i.e post a message) after the DataField was updated!? There must be an Object Property I missed when I was migrating from the 4.22. Any idea what could be missing

    Thanks

    IDE : BCB6
    WPTools: 6.0
    Database: Oracle10g
    OS : MS XP (SP3)

  • Julian, Hi

    No difference, the DBRichEdit dialog remained empty even after I included the ReformatAll() call, however Refresh() call did work but I can't run the following ...

    TDataSource ds1;
    TDBWPRichText DBRichEdit;

    ds1->DataSet = <ADO Query>;
    DBRichEdit->DataSource = ds1;
    DBRichEdit->DataField = String("<Field Name>");
    DBRichEdit->Refresh();
    DBRichEdit->SelectAll(); <----- does not select

  • Hi,

    The 4.22 ver of the TWPDBRichText got updated with the Oracle LOB content right after the Query FieldsName assignment! My expectation was to see as a minumum the same behaviour but I had to resort to 'Refresh()' to confirm the data was retrieved.

    The aim of the exercise was to debug an issue with TWPDBRichText which is not Streaming the data out as an "RTF" format to an external file and rather than the RichText content we are getting just the RichText Controls when I load the RichText content back into the TWPDBRichText!?

    The following code works perfect with ver 4.22
    To Export in RTF format

    TMemoryStream* mStream = new TMemoryStream();

    WpDBRichText->SelectAll();
    WpDBRichText->TextSaveFormat = "RTF";
    WpDBRichText->SaveToStream(mStream);

    To Retrieve in RTF Format

  • Hi, again

    I just got cut off

    and to retrieve

    WpDBRichText->Changing();
    WpDBRichText->Lines->LoadFromFile(rtfFile);

    The WPDBRichText object was updated with RichText as soon as LoadFromFile was complete with ver 4.22, but now it also needs a Refresh().

    I know the ver 6.0 of the WPTOOLS is addressing the streaming of a Formatted content differently but so far haven't been able to locate anything which shows me how to correct for it.

    Thanks

    • Offizieller Beitrag

    Hi,

    I would not recommend to use this code.

    To load the text into a TWPRichtext use

    WPRichtext1.AsString := Field.AsString;

    to save it use

    WPRichText1.AsANSIString('RTF')

    You do not need to use SelectAll.

    Instead of strings You can use streams, too: LoadFromStream and SaveToStream. But do not use the Lines property.

    If you database already contains RTF I would just save the field to a stream or string.

    Julian

  • Hi,

    The following call managed to compile with a warning

    On the Export:

    WPDBRichText->AsANSIString('RTF');
    [C++ Warning] : W8098 Multi-character character constant
    WPDBRichText->SaveToStream(mStream);

    On the Import:

    WPDBRichText->AsANSIString('RTF');
    [C++ Warning] : W8098 Multi-character character constant
    WPDBRichText->LoadFromFile(rtfFile); <--- did not load anything

    I know you indicated not to use the 'Lines' property but how else I can extract the file content?

    Also Should I just ignore the Compiler Warning or I am not using the call correctly?

  • Hi,

    Based on your last reply and what you'v already posted related to problems with TWPDBRichText I am guessing that I would be better off using the TWPRichText instead. If that is the case can you please elaborate on the following
    WPRichtext1.AsString := Field.AsString;

    Any sample code which correctly ties the 'Field' to a query

    Thanks

  • Hi

    Thanks to your last e-mail I managed to resolve the problem with
    the following, the same approach also worked fine with the Stream

    WPRichtext1->AsString = Qry->Field->AsString;
    WPDBRichtext1->AsString = WPRichtext1->AsString;

    Again Thanks

    • Offizieller Beitrag

    Hi,

    Why don't You use a TWPRichText for the display of the text and dump the TDBWPRichText?

    This loads the text
    WPRichtext1->AsString = Qry->Field->AsString;

    This saves the text (in the "Post" event)
    Qry->Field->AsString = WPRichtext1->AsString;

    Your example:

    Code
    WPRichtext1->AsString = Qry->Field->AsString; 
    WPDBRichtext1->AsString = WPRichtext1->AsString;

    could be simplified to
    WPDBRichtext1->AsString = Qry->Field->AsString;

    Julian

  • Julian,

    I realized that as soon as I hooked the query to the WpRichText component. But the extra step is not required in this case since I am only moving the RTF content to a file.

    For places that we actually use the WpDbRichText object to display the RTF content from the database the extra steps poses a problem since everything goes through the 'DataSource' objects.