Recent

Author Topic: Database and Richedit Component  (Read 8147 times)

manhu

  • New Member
  • *
  • Posts: 27
Database and Richedit Component
« on: September 18, 2015, 11:08:32 am »
Hi

I searched quite a lot for a Richedit Component where i can access the Database directly.
I found lzRichEdit, RichMemo and also KMemo but with no Database Access.
I now that i can load the Memofield with a Stream but since i use quite a lot of Memofield's i taught i would be more confined to do it "directly".
I did found a RichMemo "clone" from CodeTyphoon pl_RichMemo but it seams like it does not work.

Thanks for any Suggestions.
Manfred

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: Database and Richedit Component
« Reply #1 on: September 18, 2015, 12:12:15 pm »
TDbMemo?

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Database and Richedit Component
« Reply #2 on: September 18, 2015, 12:48:05 pm »
TDbMemo?
TDBMemo doesn't do richedit (rtf).

@manhu, do you need richedit or will just text (memo) do?

manhu

  • New Member
  • *
  • Posts: 27
Re: Database and Richedit Component
« Reply #3 on: September 18, 2015, 01:21:31 pm »
I should have richedit

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Database and Richedit Component
« Reply #4 on: September 18, 2015, 02:24:48 pm »
I'm also very surprised there isn't a DB aware RichMemo component yet for Lazarus in the default installation.

You could try TDBRichMemo from here:
http://forum.lazarus.freepascal.org/index.php/topic,26810.msg167231.html#msg167231

I had no problem installing this together with the RichMemo package:
http://wiki.freepascal.org/RichMemo#Download

manhu

  • New Member
  • *
  • Posts: 27
Re: Database and Richedit Component
« Reply #5 on: September 18, 2015, 03:02:31 pm »
Hi rvk

tanks for your Idea.  :)
Did successfully install the TDBRichMemo but i do not get any content from the Memo filed in the DB. I i chose a normal Textfiled in the DB, then it is displayed.
Any Idea?

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Database and Richedit Component
« Reply #6 on: September 18, 2015, 03:14:32 pm »
For me it worked perfectly (Laz1.5 but 1.4.2 should work too, Windows 10 with Firebird 2.1 database and TIBConnection/TSQLQuery).

What DB are you using and what DB-components?

And how did you create the RichEdit-text-field in your DB?
It shouldn't be TEXT but BLOB (or something similar for your DB-engine).
(and who and how was the field originally filled in?)

i.e.
Code: [Select]
CREATE TABLE TESTTABLE
(
  ID       BIGINT,
  TEKST    BLOB SUB_TYPE 0 SEGMENT SIZE 80
)
« Last Edit: September 18, 2015, 03:17:30 pm by rvk »

manhu

  • New Member
  • *
  • Posts: 27
Re: Database and Richedit Component
« Reply #7 on: September 18, 2015, 04:09:50 pm »
I use this Environment:
- MySQL
- RemObject DataAbstract
- The Field is a mediumtext Field
- The Field was Filled with a Delphi Programm with a CopyCat Komponent

In phpMyAdmin the Field looks normal.

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Database and Richedit Component
« Reply #8 on: September 18, 2015, 04:23:43 pm »
In phpMyAdmin the Field looks normal.
What do you mean by "normal"?
Does it contain {\rtf1\ansi\ at the beginning?
Or does phpMyAdmin have a richedit component (which I would find very surprising)?

I not sure mediumtext may/can not contain RTF code for formatted text.

So I'm not sure what you are "seeing" in phpMyAdmin.

manhu

  • New Member
  • *
  • Posts: 27
Re: Database and Richedit Component
« Reply #9 on: September 18, 2015, 04:32:12 pm »
Sorry for being unclear
Quote
What do you mean by "normal"?
Does it contain {\rtf1\ansi\ at the beginning?
Of course i meant that.  O:-)

Quote
{\rtf1\ansi\ansicpg1252\deff0\deflang2055{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
\viewkind4\uc1\pard\f0\fs16 dfgdfg\par
}

In a DBEdit it also look that way.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Database and Richedit Component
« Reply #10 on: September 18, 2015, 04:58:38 pm »
It shouldn't be TEXT but BLOB (or something similar for your DB-engine).
(and who and how was the field originally filled in?)
Oddly enough, it seems like it. If the field is not BLOB it would not load rtf.
(the check for .IsBLOB in most of TDBRichMemo methods).

Adding TDBRichXXXX component to the default LCL components package requires a full-time maintainer :)

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Database and Richedit Component
« Reply #11 on: September 18, 2015, 05:37:50 pm »
There are just 3 .IsBlob checks in dbrichmemo.pas.

So adding "true and " in front of the check will always result in being true.
Easy enough to check if it works after that.
But (in Delphi/Firebird) I've always used BLOB for RTF-data.

Code: [Select]
    if (true and DataLinkField.IsBlob) then begin
...
  if not FDBMemoLoaded and (FDataLink.Field<>nil)
  and (true and FDataLink.Field.IsBlob) then begin
...
  if FDBMemoLoaded and (FDataLink.Field<>nil)
  and (true and FDataLink.Field.IsBlob) then begin

Of course you could also completely remove the .IsBlob check but this way you can see what you've done  :)

manhu

  • New Member
  • *
  • Posts: 27
Re: Database and Richedit Component
« Reply #12 on: September 18, 2015, 10:56:41 pm »
Thank you for your advice.
Will try that on Monday.
Shalom Manfred

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Database and Richedit Component
« Reply #13 on: September 19, 2015, 11:00:04 am »
rvk, you actually mean "true or", don't you?
Because, (true and DataLinkField.IsBlob) will return the same as DataLinkField.IsBlob.

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Database and Richedit Component
« Reply #14 on: September 19, 2015, 12:46:13 pm »
rvk, you actually mean "true or", don't you?
Woops, yes (true), I do of course  :-[

Code: [Select]
    if (true or DataLinkField.IsBlob) then begin
...
  if not FDBMemoLoaded and (FDataLink.Field<>nil)
  and (true or FDataLink.Field.IsBlob) then begin
...
  if FDBMemoLoaded and (FDataLink.Field<>nil)
  and (true or FDataLink.Field.IsBlob) then begin

Thanks (I must have been momentarily blind there  :D).

 

TinyPortal © 2005-2018