Hello there,
I'm trying to search a special value into my database but it just doesn't want to get there.
I'm using QSQLITE to connect to my database and i'm using the following code to reach a value :
void DbManager::printCommande(int id)
{
QSqlQuery query
("SELECT * FROM commandes WHERE id=(:id)");
query.bindValue(":id", id);
int idId = query.record().indexOf("id");
int idmagasin = query.record().indexOf("idMagasin");
int idclient = query.record().indexOf("idClient");
int idDate = query.record().indexOf("date_commande");
int idEmploye = query.record().indexOf("EmployeResponsableVente");
int idPaiement = query.record().indexOf("mode_paiement");
while (query.next())
{
QString name
= query.
value(idId
).
toString();
qDebug() << name;
QString magasin
= query.
value(idmagasin
).
toString();
qDebug() << magasin;
QString client
= query.
value(idclient
).
toString();
qDebug() << client;
QString date
= query.
value(idDate
).
toString();
qDebug() << date;
QString employe
= query.
value(idEmploye
).
toString();
qDebug() << employe;
QString paiement
= query.
value(idPaiement
).
toString();
qDebug() << paiement;
}
}
void DbManager::printCommande(int id)
{
QSqlQuery query("SELECT * FROM commandes WHERE id=(:id)");
query.bindValue(":id", id);
int idId = query.record().indexOf("id");
int idmagasin = query.record().indexOf("idMagasin");
int idclient = query.record().indexOf("idClient");
int idDate = query.record().indexOf("date_commande");
int idEmploye = query.record().indexOf("EmployeResponsableVente");
int idPaiement = query.record().indexOf("mode_paiement");
while (query.next())
{
QString name = query.value(idId).toString();
qDebug() << name;
QString magasin = query.value(idmagasin).toString();
qDebug() << magasin;
QString client = query.value(idclient).toString();
qDebug() << client;
QString date = query.value(idDate).toString();
qDebug() << date;
QString employe = query.value(idEmploye).toString();
qDebug() << employe;
QString paiement = query.value(idPaiement).toString();
qDebug() << paiement;
}
}
To copy to clipboard, switch view to plain text mode
I've looked for a bit for a soluton but everywhere i've looked for the previous code worked for everybody but not me so i'm quite in a bind here.
I checked if it would work if I changed the (:id) into an int and it worked so I guess it's how I call the id that causes problems but i quite don't get it.
thanks in advance for your help
Bookmarks