lundi 29 décembre 2014

Qt SQL query.exec Always Returning True

Im creating a login system in qt using a database but when I run the query in qt it is always returning true, even when that item is false.


The sql database connection code is below



QSqlDatabase login = QSqlDatabase::addDatabase("QSQLITE");
login.setDatabaseName("/Users/Daniel/Dropbox/Stock_Control.sqlite");
if(!login.open())
ui->label->setText("Unable To Connect To Database");


The SQL query code is below



static Home *home = new Home;
QSqlQuery query;
QString Username = ui->Username_lineEdit->text();
QString Password = ui->Password_lineEdit->text();
if(query.exec("SELECT Login FROM Program_account WHERE Login = '"+ Username +"' AND Password = '"+ Password +"' "))
{
tries = 0;
home->show();
close();
}


Thank you


Aucun commentaire:

Enregistrer un commentaire