Forum > Databases

[SOLVED] (MEMO)s in my TDBComboBox

(1/2) > >>

Slyde:
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:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.CommentsGetTextHandler(Sender: TField; var aText: string;  DisplayText: Boolean);begin  AText := Sender.AsString;end;
See attached demo.

Zvoni:
wp,
SQLite doesn't have a Memo-Type for its fields

OP,
change your SQL to

--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SELECT CAST(MyTextField AS CHAR) AS MyField FROM TABLE
And no, using SELECT * FROM Table is not an excuse for you.....

Slyde:
@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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
Try

--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SELECT CHAR(MyTextField) AS NameFIeld FROM TABLEI remember having that too, and i think i solved it that way (not with CAST)

Navigation

[0] Message Index

[#] Next page

Go to full version