Mysql with Qt query [solved]
-
Hello Forum,
i have a question about MYSQL Syntax in Qt. I have a table with the name "min5_1" an i have problems with the query.
The Code:
@ MainWindow main;
this->comboxLaden();
QString tableName = ui->tablesBox->currentText();
qDebug() << tableName;
QSqlQueryModel *model = new QSqlQueryModel();
QSqlQuery *qry = new QSqlQuery(main.mydb1);
qry->prepare("SELECT * FROM '"+tableName+"' ");
if(qry->exec())
{
qDebug() << "If schleife";
model->setQuery(*qry);
ui->anzeigenView->setModel(model);
}
else
qDebug() << "Else" << qry->exec();@The exec is always false. When i changed the var "tableName" to "min5_1" the query is true. What doing false?
Alex
-
try to debug the error, something like:
@qDebug() << qry->lastError()->text();@