Forum > Lazarus Extra Components
[SOLVED] FPreport print date base64 encoded
(1/1)
dseligo:
I have SQL like this (DB is SQlite):
--- Code: MySQL [+][-]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 date(insert_date_time) as insert_datefrom sometable
Column insert_date_time in SQlite is defined like this:
--- Code: Text [+][-]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";}};} ---insert_date_time datetime default (datetime(current_timestamp, ''localtime''))
Memo in FPreport is created like:
--- 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";}};} --- Memo := TFPReportMemo.Create(FDataBand); Memo.Layout.Left := ALeft; Memo.Layout.Width := AWidth; Memo.Layout.Top := ATop; Memo.Layout.Height := AHeight; Memo.Font.Name := AFont; Memo.Font.Size := AFontSize; Memo.TextAlignment.Horizontal := AHorAlignment; Memo.Text := '[insert_date]';
These are values I get in FPreport (exported to PDF):
--- Code: Text [+][-]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";}};} ---MjAyNS0wNy0wMw==MjAyNS0wNy0xMw==MjAyNS0wNy0xNQ== MjAyNS0wNy0xOA==
With this:
--- 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";}};} ---WriteLn(Query1.FieldByName('insert_date').AsString);WriteLn(Query1.FieldByName('insert_date').FieldDef.DataType);
I get (for first row):
--- Code: Text [+][-]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";}};} ---2025-07-03ftMemo
What could be the cause?
I tried this on FPC 3.2.2 on Windows 11 and Android.
anse:
SQLite does not care much about defined column data types, and not even about results of functions like DATE() - most of them just return strings (which could be the cause of ftMemo), and the underlying driver you use does not really get information about the originated data type.
dseligo:
I don't mind string. Question is why FPreport encode this string in base64. And how do I prevent this.
rvk:
Probably because FPC considers TEXT from SQLite as memo and not as string. Same reason you get (memo) in a tdbgrid. I find this a wrong choice which was introduced some years ago.
TEXT should have stayed a field type ftstring (as it was before).
Similar topic here
https://forum.lazarus.freepascal.org/index.php?topic=62022.0
You can cast to a varchar or use gettext to return string (same as the solution for tdbgrid).
dseligo:
--- Quote from: rvk on September 15, 2025, 09:14:18 pm ---Probably because FPC considers TEXT from SQLite as memo and not as string. Same reason you get (memo) in a tdbgrid. I find this a wrong choice which was introduced some years ago.
TEXT should have stayed a field type ftstring (as it was before).
Similar topic here
https://forum.lazarus.freepascal.org/index.php?topic=62022.0
You can cast to a varchar or use gettext to return string (same as the solution for tdbgrid).
--- End quote ---
Thank you for the link, solution from answer #5 (from paweld) worked. Casting doesn't work for me.
Navigation
[0] Message Index