dsant
24th April 2013, 12:50
Hello, this code is working OK :
QSqlQuery query(mybase);
query.prepare("SELECT name FROM mytable");
if( ! query.exec() )
cout << "error SQL= " << query.lastError().text().toStdString() << endl;
else
cout << "Ok" << endl;
But if I change the 3 lines :
QSqlQuery query(mybase);
query.prepare("SELECT :tag_array FROM :tag_table");
query.bindValue(":tag_array","name");
query.bindValue(":tag_table","mytable");
if( ! query.exec() )
cout << "error SQL= " << query.lastError().text().toStdString() << endl;
else
cout << "Ok" << endl;
I have this error at execution time :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':tag_array FROM :tag_table' at line 1 QMYSQL: Unable to execute query
Did I did a mistake ?
QSqlQuery query(mybase);
query.prepare("SELECT name FROM mytable");
if( ! query.exec() )
cout << "error SQL= " << query.lastError().text().toStdString() << endl;
else
cout << "Ok" << endl;
But if I change the 3 lines :
QSqlQuery query(mybase);
query.prepare("SELECT :tag_array FROM :tag_table");
query.bindValue(":tag_array","name");
query.bindValue(":tag_table","mytable");
if( ! query.exec() )
cout << "error SQL= " << query.lastError().text().toStdString() << endl;
else
cout << "Ok" << endl;
I have this error at execution time :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':tag_array FROM :tag_table' at line 1 QMYSQL: Unable to execute query
Did I did a mistake ?