[SOLVED] (MEMO)s in my TDBComboBox lazarus / 16-Databases ---------------------------------------------------------------------- Slyde · 2022-06-16 15:49 I can't get rid of these things.  I know that you have to enable dgDisplayMemoText in Option of the TDBGrid in the Object Inspector to get rid of them, but TDBComboBox doesn't have that flag.  I'm using it to load names from a SQLite3 db table, which is populated, and all I get is the (MEMO) in place of the names.  I can't ever recall a TDBComboBox displaying (MEMO) in place of the actual data.  But this one is. Any ideas/suggestions? ---------------------------------------------------------------------- wp · 2022-06-16 17:39 You probably assigned to the DBCombobox a field which is a memo. If you have the possibility to change the field definitions change it to a string field of fixed length. If this is not possible you can assign a handler for the OnGetText event to the memo field. Assign the result of the field's AsString property to the string output variable of the handler: 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 procedure TForm1.CommentsGetTextHandler(Sender: TField; var aText: string;  DisplayText: Boolean);begin  AText := Sender.AsString;end; See attached demo. ---------------------------------------------------------------------- Zvoni · 2022-06-17 06:13 wp, SQLite doesn't have a Memo-Type for its fields OP, change your SQL to Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT CAST(MyTextField AS CHAR) AS MyField FROM TABLE And no, using SELECT * FROM Table is not an excuse for you..... ---------------------------------------------------------------------- Slyde · 2022-06-17 09:49 @Zvoni: I wasn't using SELECT * for my query.  Just the one field.  However, in using your suggestion, the DBComboBox still loaded with (MEMO)s.  This is what I have for it: 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 procedure TForm1.ReloadComboBox;begin  DBComboBox1.Clear;  ZQ2.Close;  ZQ2.SQL.Text := 'SELECT CAST(name AS CHAR) AS nameField FROM pupils';  ZQ2.Open;  ZQ2.First;  while not ZQ2.EOF do  begin    if ZQ2.FieldByName('nameField').AsString <> '' then      DBComboBox1.Items.Add(ZQ2.FieldByName('nameField').DisplayText);    ZQ2.Next;  end;  DBComboBox1.Sorted := True;end; I'm not sure what else to do.  One wld think this wldn't be an issue in 2022, that this wld've been ironed out years ago.  But here we are, still fighting it. ---------------------------------------------------------------------- Zvoni · 2022-06-17 10:13 Try Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT CHAR(MyTextField) AS NameFIeld FROM TABLEI remember having that too, and i think i solved it that way (not with CAST) ---------------------------------------------------------------------- Slyde · 2022-06-17 10:56 This works: 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 procedure TForm1.ReloadComboBox;begin  DBComboBox1.Clear;  ZQ2.Close;  ZQ2.SQL.Text := 'SELECT name FROM pupils';  ZQ2.Open;  ZQ2.First;  while not ZQ2.EOF do  begin      DBComboBox1.Items.Add(ZQ2.FieldByName('name').AsString);  // changed .DisplayText to .AsString    ZQ2.Next;  end;  DBComboBox1.Sorted := True;end; Thanks for your input, Zvoni.  It pushed me in the right direction. ---------------------------------------------------------------------- Zvoni · 2022-06-17 12:01 Just saw it: You'll have to explain why you use a TDBComboBox, which is a Data-aware Control, when you're manually filling it up. That's why i stumbled with the SQL ---------------------------------------------------------------------- Slyde · 2022-06-17 12:17 Already ahead of you.  I changed that to a regular TComboBox after I ran a few checks on the DBComboBox.  When I first added that DBComboBox and hard-wired the SQL string of the ZEOS Query component, it just loaded one (MEMO).  So I added the Reload procedure, and that did add all the table rows.  But all were (MEMO).  That brought me here, to the forum.  And right after posting the above, I saw that I cldn't select anything from the DBComboBox.  A TComboBox solved that.