Problem saving to database

  • Hello all,

    a few days ago I licensed WPTools 6.10 Standard, so I am not yet really familiar with it. I searched this forum, but couldn't find an answer to my problem:

    In a Delphi project I a have a form with a TDBWPRichText control that is bound to a memo field in an Access database.

    Everything is fine - text can be loaded, formatted and saved.

    When I show the memo field in another Rich Text control (not WPCubed) only question marks and some other formatting characters appear. When looking directly into the memo field in the underlying database the content of the memo field displays something like chinese characters (and not, as expected, a string like '{\rtf1\ansi\deff0\uc1\a....').

    I tried the following:
    Loading the memo into an unbound TWPRichText with
    Self.WPRichText1.AsString := theDataSource.DataSet.Fields.FieldByName('Body').AsString;
    works. The text can be edited and formatted and saved back to the database with:
    Self.ADOQuery1.Fields.FieldByName('Body').AsString := Self.WPRichText1.AsString;
    Self.ADOQuery1.Post;

    After this procedure, the memo field contains '{\rtf1\ansi\deff0\uc1\a....', that can be interpreted by other Rich Text controls.

    For me, this is absolutely necessary, because the rich text must be displayed, for example in a grid.

    So, the question is:
    How can I make the TDBWPRichText control load and save rich text in 'pure' format ({\rtf1...) - which properties must be set? I think the 'workaround' with first loading into 'normal' WPRichText component is one step to much, or?

    Environment:
    Windows 7
    Delphi 2007

    Thank you very much in advance
    Joe

  • Joe,

    you'd be VERY much better off using the workaround with a normal TWPRichText!

    The DB-version works differently. I started to use the DB-version and after it was too late to undo everything (and redo it with the normal version) we realized several issues which bugged us deeply and cost much time as well.

    Julian himself often advises to not use the DB-version.

    That said, i still like to work with WPTools - don't get me wrong.

    Hope that helps,
    Wolfgang

  • Hello Wolfgang,

    thank you for your reply.

    Ok then - I will forget the databound control, although I wonder why it exists if there are so many problems...

    Anyway, this is a big step for me to take the right direction.

    Best regards
    Joe

    • Offizieller Beitrag

    Hi,

    It is not so that the DB control does not work in General.

    But it has 2 problematic areas:

    1) switching the database automatically to edit mode.

    This happens the first time the user tries to change anything. The "DB sensitve" system will reload the text in this moment, invalidates any pointers. For selections this is no problem, they can be restored. It is problematic when objects or tables are selected and also when the text is rather large.

    2) loading & saving unicode

    For some databases Memos are saved as unicode, RTF however is a single byte storage format and should be saved in a blob.

    If somebody has an idea how to modify WPDBRICH.PAS to take account for different database systems, please share :-)

    Julian