Quantcast
Channel: Qt DevNet forums: Installation and Deployment
Viewing all articles
Browse latest Browse all 2113

[Solved] Qt problem with query in SQLite database in Qt

$
0
0
Hi, I am facing this problem: QString name, passwd;     name=ui->nom->text();     passwd=ui->motdepasse->text();     if(!mydb.isOpen())     {        ui->label_2->setText("pas de connexion");        //qDebug()<<"Failed to open my database";        //return;     }     QSqlQuery qry;     if(qry.exec("SELECT * FROM emploi WHERE ref='"+passwd+"' AND entreprise='"+name+"'"))     {         int count=0;         while(qry.next())         {             count++;         }         if(count==1)              ui->label_2->setText("username and passwd are correct");           else if(count>1)              ui->label_2->setText("duplication");           else              ui->label_2->setText("this count does not exist");         }     else ui->label_2->setText("errors"); } When running I get the message “errors” that mean the query exec return false. Also when I replace the previous query with  if(qry.exec("SELECT * FROM emploi WHERE ref=0 AND entreprise='alcatel'")) the program run correctly and poster this message “username and passwd are correct”(I have it in my table emploi). Can someone help me and thank you.

Viewing all articles
Browse latest Browse all 2113

Trending Articles