Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sqlite.ToQmGrid - problems with escaped characters
Hi Gintaras,
I am using a sqlite db to maintain a user list. Some of the names have apostrophe like "O'Connor" so I use
this before populating db table row:
Copy      Help

To look at all table entries, I fill a QM grid with the table contents:

Copy      Help
DlgGrid g0.Init(hDlg 1005);;Enrollment Gridt_db.ToQmGrid(g0 "SELECT * FROM RadEnrollment" 1);err

The problem is that the table is filled with the Escaped version e.g. "O''Conor" instead of "O'Conor".
How do I de-escape using ToQmGrid?

Exec unescapes '' and adds single ' to database.

Function sample_Grid_Sqlite2
Copy      Help
function# hDlg message wParam lParam

;Shows how to use grid control with Sqlite database.

if(hDlg) goto messages

str- t_dbfile="$desktop$\test82.db3"
Sqlite- t_db


;create database for testing
Sqlite db1.Open(t_dbfile)
db1.Exec("CREATE TABLE IF NOT EXISTS table1 (A)")
str name="O'Connor"
db1.Exec(F"INSERT INTO table1 VALUES ('{name}')")

if(!ShowDialog("" &sample_Grid_Sqlite2)) ret

;0 "" 0x90C80AC8 0x0 0 0 338 135 "Dialog"
;3 QM_Grid 0x54030000 0x0 0 0 338 114 "0x0,0,0,0,0x0[]A,,,"
;1 Button 0x54030001 0x4 4 118 48 14 "OK"
;2 Button 0x54030000 0x4 56 118 48 14 "Cancel"
;DIALOG EDITOR: "" 0x2030400 "" "" ""

DlgGrid g.Init(hDlg 3)
sel message
,;open database and add table1 to the grid control
,t_db.ToQmGrid(g "SELECT * FROM table1")
,case WM_COMMAND goto messages2
sel wParam
,case IDOK
ret 1
Thanks Gintaras,
I am using your example to figure this problem out. I am not familiar with the F" syntax. Where can I find this in QM?
Thanks, S
F"string {variable}"

is the same as

_s.format("string %s" variable)

It is not related to databases, but convenient to use instead of format.

Help / Strings with variables
Thanks so much. I didn't realize that FromQmGrid also has the SqlEscape in it so I was double escaping!

Forum Jump:

Users browsing this thread: 1 Guest(s)