[Qt-interest] Problem with QSqlQuery::prepare with a stored procedure (MySql)
Stephan Rose
kermos at somrek.net
Fri Dec 5 18:32:03 CET 2008
As the subject states, the database connected to is a MySql Database.
The following code works perfectly:
QSqlQuery query;
query.exec("call storedProcedure(1)");
while(query.next()){...}
However, since the procedure does take a parameter, I originally used this code:
QSqlQuery query;
query.prepare("call storedProcedure(:param)");
query.bindValue(":param",1); // Constant 1 used for example purposes
query.exec();
while(query.next()){...}
And it fails, query.next() returns false. Both prepare and exec however return true and lastError() is always empty. However, I do see this on the console debug output:
QMYSQLResult::cleanup: unable to free statement handle
Then to simplify the problem I reduced it to this:
QSqlQuery query;
query.prepare("call storedProcedure(1)");
query.exec();
while(query.next()){...}
Again, same results. prepare & exec = true, query.next() = false. lastError() again returns nothing and I also see "QMYSQLResult::cleanup: unable to free statement handle" on the console.
Any ideas?
Thanks,
Stephan
More information about the Qt-interest-old
mailing list