DBGrid showing (MEMO) instead desired string. lazarus / 16-Databases ---------------------------------------------------------------------- aamaral · 2021-09-08 01:24 I'm on this very simple piece of code but I couldn't do it work properly. I dropped into form a LibraryLoader and set the absolute path to .dll, a SQLite3Connection and set the absolute path to database, a SQLQuery, a DataSource (that points to the SQLQuery) and a DBGrid linked to that DataSource. In SQL Property of SQLQuery I have the following statement: 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 nome AS "NOME",strftime("%d/%m/%Y", DATE(dt_apfd)) AS "APFD",strftime("%d/%m/%Y", DATE(dt_prev)) AS "PREV",numero AS "PROCESSO"FROM presos INNER JOIN processosON processos.idproc = presos.idproc; For load results into DBGrid I'm using the code: 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.Button1Click(Sender: TObject);begin  SQLite3Connection1.Open;  DBGrid1.Columns.Clear;   SQLQuery1.Active:=True; //SQLQuery1.FieldDefs [0].DataType:=TFieldType.ftString;  DBGrid1.Columns.Add;  DBGrid1.Columns[0].FieldName:=SQLQuery1.FieldDefs[0].Name;  DBGrid1.Columns.Add;  DBGrid1.Columns[1].FieldName:=SQLQuery1.FieldDefs[1].Name;  DBGrid1.Columns.Add;  DBGrid1.Columns[2].FieldName:=SQLQuery1.FieldDefs[2].Name;  DBGrid1.Columns.Add;  DBGrid1.Columns[3].FieldName:=SQLQuery1.FieldDefs[3].Name;end; The Problem: when I activete SQLQuery, DBGrid is showing (MEMO) on filds "NOME" and "PROCESSO" instead the actually string. As you can see, I tried to ``SQLQuery1.FieldDefs[0].DataType:=TFieldType.ftString;``, but it mades no difference. I tried to change it via Properties, but actually, catch fields and its properties by activating the query has a bug wich crashes Lazarus to death, so I was trying to do it writting in program. ---------------------------------------------------------------------- GAN · 2021-09-08 02:40 QuoteThe Problem: when I activete SQLQuery, DBGrid is showing (MEMO) on filds "NOME" and "PROCESSO" instead the actually string. To solve this you have to enable dgDisplayMemoText in Option of the TDBGrid in the Object Inspector. ---------------------------------------------------------------------- Zvoni · 2021-09-08 07:02 Or cast it to VARCHAR in your Select-Statement SELECT CAST(Nome As Varchar) As Nome From...." ---------------------------------------------------------------------- aamaral · 2021-09-09 00:16 Thank you guys for such a quick reply. I tested both solution separately. Casting my fields in Select statement worked like a charm. Changing property dgShowMemoText in design time, it raised following exception when while running I clicked on Button1 to populate DBGrid: "External: SIGSEGV" - In address xxxxxxxxxx. But, changing same property in code, it worked perfectly. 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.Button1Click(Sender: TObject);var  myDbGridOpts: TDbGridOptions;begin  SQLite3Connection1.Open;  DBGrid1.Columns.Clear;   myDbGridOpts:=[];  Include(myDbGridOpts,dgColLines);  Include(myDbGridOpts,dgDisplayMemoText);  Include(myDbGridOpts,dgIndicator);  Include(myDbGridOpts,dgRowSelect);  Include(myDbGridOpts,dgTitles);   SQLQuery1.Active:=True;   DBGrid1.Columns.Add;  DBGrid1.Columns[0].FieldName:=SQLQuery1.FieldDefs[0].Name;  DBGrid1.Columns.Add;  DBGrid1.Columns[1].FieldName:=SQLQuery1.FieldDefs[1].Name;  DBGrid1.Columns.Add;  DBGrid1.Columns[2].FieldName:=SQLQuery1.FieldDefs[2].Name;  DBGrid1.Columns.Add;  DBGrid1.Columns[3].FieldName:=SQLQuery1.FieldDefs[3].Name;  DBGrid1.Options:=myDbGridOpts;end;