[Qt-interest] Why the sql sentence can't be exec in QSqlQuery?
Andreas Ntaflos
daff at pseudoterminal.org
Sun Jun 14 17:59:40 CEST 2009
On Sunday 14 June 2009 17:51:49 Kermit Mei wrote:
> But in my Qt4 code:
>
> query.exec("SELECT text,pos_x,pos_y,size_x,size_y"
> "FROM WidgetItem"
> "INNER JOIN CWPage"
> "ON WidgetItem.CWPageId=CWPage.id;")
You need to put in spaces where appropriate in this string, i.e.:
query.exec("SELECT text,pos_x,pos_y,size_x,size_y"
" FROM WidgetItem"
" INNER JOIN CWPage"
" ON WidgetItem.CWPageId=CWPage.id;")
Otherwise the string that would eventually be parsed by the SQL driver
would look something like this:
"SELECT text,pos_x,pos_y,size_x,size_yFROM WidgetItemINNER JOIN \
CWPageON WidgetItem.CWPageId=CWPage.id;"
Clearly not valid SQL. I've been bitten by this myself a few times.
HTH
Andreas
--
Andreas Ntaflos
Vienna, Austria
GPG Fingerprint: 6234 2E8E 5C81 C6CB E5EC 7E65 397C E2A8 090C A9B4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2494 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090614/a0685bd8/attachment.bin
More information about the Qt-interest-old
mailing list