PDA

View Full Version : how to use database value in the variable



akkarachai
2nd December 2019, 07:45
QString timess;
QSqlQuery qry;
qry.prepare("SELECT FROM test WHERE time = '"+timess+"'");
if (qry.exec()){
ui->time->setText(timess);
qDebug("timess");
};

This is my code. after I Run ui didn't show anything.

I create timess with qstring and store the time value from database(SQLite) into it's.
But in the time ui (QLable) didn't show anything after I run the process.
:confused:

Lesiok
2nd December 2019, 11:26
1. SQL query is incorrect - You must indicate what you want select.
2. Read about QSqlQuery::next and QSqlQuery::value.