Recent

Author Topic: Table field showing Memo  (Read 4919 times)

linuxdesire

  • New Member
  • *
  • Posts: 11
Table field showing Memo
« on: September 22, 2016, 10:25:46 pm »
I am using Lazarus Free Pascal Version #1.6. I was following a tutorial from http://www.alevel-computing.x10.mx/TutorialLazarusSQLite.php#LazarusComponents

I am also using SQLite3

When I run the database I get "Memo" written in the fields that are holding my text. I have been researching and reading different things about this but cannot figure it out. How do I correct this?

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: Table field showing Memo
« Reply #1 on: September 23, 2016, 07:20:38 am »
What data type is your column in table in SQLite database ?
I expect, that it is declared as TEXT or CLOB ?
Then is is expected, that such column can hold large textual string, which possibly can not be displayed in one row in TDBGrid.
If you know, that text can be displayed, you can use own event handler for TField http://www.freepascal.org/docs-html/3.0.0/fcl/db/tfield.ongettext.html where you can return :
AText := Sender.AsString;

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Table field showing Memo
« Reply #2 on: September 23, 2016, 09:57:50 am »
The example you point to used VARCHAR(20) to create text-fields. Did you do the same of used TEXT or something else?

If you used TEXT you might want to change that to VARCHAR(20) (where 20 is the maximum length of the text). And even though you give VARCHAR a length, in SQLite this is ignored and all fields are actually unlimited. (SQLite is really unlike other DBs when it comes to defining datatypes) But Lazarus does use that length to fill in the field-data and the columns of a DBGrid will then use that.

https://www.sqlite.org/datatype3.html

totya

  • Hero Member
  • *****
  • Posts: 720

 

TinyPortal © 2005-2018