Looking at the related Qt source code gives another idea: in 4.8 when you passed the statement string to QSqlQuery constructor, it tried to execute the query, failed due to placeholders making the statement syntactically incorrect (but lack of error checks in your code hid the problem), and then performed the actual execution in exec(). So it's probably not as coincidental as I thought but still undocumented and therefore fragile, 5.1 just fixed that. On May 24, 2013 7:45 AM, "Constantin Makshin" <cmaks...@gmail.com> wrote:
> http://qt-project.org/doc/qt-4.8/qsqlquery.html#QSqlQuery-2 says the > constructor you used executes the query passed to it. > > http://qt-project.org/doc/qt-4.8/qsqlquery.html#bindValue says it's meant > to be used with prepared queries. > > So my opinion is that the fact that the code you used in Qt 4 worked is > purely a coincidence showing unintended/undocumented behavior. > On May 23, 2013 1:31 AM, "Guido Seifert" <warg...@gmx.de> wrote: > >> >> I am wondering. >> I have a program, which runs perfectly fine with Qt 4.8. >> In dozens of places I do: >> QString queryString = "SOME SQL STATEMENT with :foo;"; >> QSqlQuery query(queryString, database); >> query.bindValue(":foo", xxxxxx); >> query.exec(); >> >> Now I tried to compile the program with Qt 5.1. Compiles fine, >> but the database stuff is totally broken. Above value binding >> does not seem to work anymore. >> >> Now I have to do: >> QString queryString = "SOME SQL STATEMENT with :foo;"; >> QSqlQuery query(database); >> query.prepare(queryString); >> query.bindValue(":foo", xxxxxx); >> query.exec(); >> >> >> Not too difficult to change, but WHY? >> >> Guido >> >> >> -- >> Guido Seifert <warg...@gmx.de> >> _______________________________________________ >> Interest mailing list >> Interest@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/interest >> >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest