DBMemo truncates string lazarus / 16-Databases ---------------------------------------------------------------------- artem101 · 2022-04-08 13:44 Hello all! I use SQLite3 database. My table has field defined with VARCHAR type (without length specified). I have TDBMemo to edit it. I see weird things: After saving to database string truncates to TField.Size x 4 characters.I tried to increase TField.Size - when I set big value (for example about 1000), my application crashes with SIGSEGV error. MaxLength property of DBMemo = 0. Could somebody explain me how Size property works and how to increase max length (or make it unlimited) for DBMemo? I have: Lazarus 2.0.12FPC 3.2.0Windows 7 64bitSQLite3 dll 3.37.2 Thanks. ---------------------------------------------------------------------- Sieben · 2022-04-08 14:16 If you want that field to be unlimited in size, change type to TEXT in your database and make sure that it is a TMemoField in your application by deleting and recreating the associated FieldDef and TField (which presumably is a TStringField right now). ---------------------------------------------------------------------- artem101 · 2022-04-08 20:04 Is any difference between VARCHAR and TEXT? In SQLite3 they are synonyms, aren't they? I add changes you advised, but now have error "dataset is not in edit or insert state". Also in DBGrid value of this field looks as (MEMO). Can you have a look at my code? ---------------------------------------------------------------------- Sieben · 2022-04-08 20:51 Quote from: artem101Is any difference between VARCHAR and TEXT? In SQLite3 they are synonyms, aren't they? As far as the database's internal storing and processing is concerned, yes. But a field reported as VARCHAR by schema info is 'translated' to a TStringField, while TEXT results in a TMemoField. QuoteI add changes you advised, but now have error "dataset is not in edit or insert state". That's another issue unrelated to the field type. Is AutoEdit of the corresponding DataSource set to True? QuoteAlso in DBGrid value of this field looks as (MEMO). That's the standard display text of a TMemoField. You can use the TField's OnGetText event to supply the real content or, better, just a sufficient part of it. Like this for instance: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  cGridMemoLength = 75;//...procedure TdmMain.MemosGetGridText(Sender: TField; var aText: string; DisplayText: Boolean);begin  if DisplayText then  begin    aText := Sender.AsString;    SetLength(aText,cGridMemoLength);    aText := ReplaceStr(aText,LineEnding,' ');    aText := aText + '...';  end;end;  Will have a look at your code as well - EDIT: but can't get it to run due to a 'malformed database schema' error. ---------------------------------------------------------------------- Zvoni · 2022-04-09 07:05 Quote from: artem101 on April 08, 2022, 10:04:25 pmAlso in DBGrid value of this field looks as (MEMO). There is an option in Object-Inspector of DBGrid, to show Memo-Text correctly, or cast the Field to Char in your Select-Statement ---------------------------------------------------------------------- artem101 · 2022-04-09 10:40 Quote from: Sieben on April 08, 2022, 10:51:56 pmIs AutoEdit of the corresponding DataSource set to True? Yes. Quote from: Zvoni on April 09, 2022, 09:05:41 amThere is an option in Object-Inspector of DBGrid, to show Memo-Text correctly How is it named? ---------------------------------------------------------------------- Sieben · 2022-04-09 10:46 Quote from: ZvoniThere is an option in Object-Inspector of DBGrid... I wasn't aware of that one - it's dgDisplayMemoText in TDBGrid.Options. Thanks! Quote...or cast the Field to Char in your Select-Statement This points to another problem in OP's code. As for now she/he is using the same DataSet/DataSource for grid display and editing. So casting (back) to VARCHAR would only mean to reintroduce the initial problem here. I'd suggest to always use a distinct DataSet/DataSource for every single purpose. ---------------------------------------------------------------------- Zvoni · 2022-04-09 12:56 Or don‘t use databound controls for editing, only for display ---------------------------------------------------------------------- artem101 · 2022-04-09 19:16 Quote from: Sieben on April 08, 2022, 10:51:56 pmWill have a look at your code as well - EDIT: but can't get it to run due to a 'malformed database schema' error. Try to remove database file (it will be created) or check your SQLite dll version (I use 3.37.2 32bit). ---------------------------------------------------------------------- Sieben · 2022-04-10 12:13 Results in the next error - 'default value for column [done] not constant'. But what exactly is your problem now?