You should check every statement that could fail (prepare() can fail, too, for example).
Also, try removing the semi-colon ";" at the end of the query.
(I remember that was a problem for me once, I was using Oracle, though.)
HTH
You should check every statement that could fail (prepare() can fail, too, for example).
Also, try removing the semi-colon ";" at the end of the query.
(I remember that was a problem for me once, I was using Oracle, though.)
HTH
TonyB (20th August 2009)
Many thanks; it was the prepare that was failing with message
Query error No 1295: This command is not supported in the prepared statement protocol yet QMYSQL3: Unable to prepare statement
Now to find a workaround.
For the record, removing the prepare() and executing the statement directly fixed the problem. Thanks again.
Raccoon29 (3rd December 2009)
Hi,
I'm using on linux
Mysql 5.0.77-1
QT Creator 1.3.1
QT Libs 4.5.1 (due to Distro compatibility)
This is my code to create DB Schema:
Qt Code:
void MainWindow::creadb() { db.setHostName("localhost"); db.setDatabaseName("mysql"); db.setUserName("root"); db.setPassword(ui->password->text()); if (db.open()) { QSqlQuery query; query.exec("create database "+db_conti); qWarning()<<query.lastError(); ... code for creating tables, views and users... db.close(); } }To copy to clipboard, switch view to plain text mode
I'm getting with qWarning() the same your error:
QSqlError(1295, "QMYSQL3: Unable ro prepare statement", "This command is not supported in the prepared statement protocol yet")
But DB Schema is created. Also tables views and users are created without problems.
Do I ignore that error?
Thanks.
Hi saa7_go,
sorry delay in answer, I was on holiday.
My complete code is in my previous post.
Row 13
Qt Code:
query.exec("create database "+db_conti);To copy to clipboard, switch view to plain text mode
db_conti contains DB Schema Name
and row 15 to get output log about this command.
DB Schema is created, but query.lastError() gives me error on create database.
thanks in advance
Are you sure that this part of your code
prints the warning? Because, you don't do prepare statement like TonyB did.
Qt Code:
qm.prepare (qs); if (!qm.exec()) { .... }To copy to clipboard, switch view to plain text mode
I've tried your code. No error or warning occurs.
Hi again,
As ToniB wrote, using qm.prepare (qs), no DB Schema is created, with non evidence of error.
ToniB suggested to remove the prepare() and execute the statement directly.
Executing directly, DB Schema is created, but I get error.
It is not a big problem, since DB is created, but I'd like, if it is possible, to fix the problem.
Tks for answer.
I think it is a bug . If you want to fix the problem, use Qt 4.6.0 or above.
Last edited by saa7_go; 21st July 2010 at 01:32. Reason: updated contents
many thanks.
Ciao.
Bookmarks