anouar2002
22nd February 2012, 20:58
Hi everyone,
I'm working on a Qt application that interacts with a SQL database Server.Je want tocompare two fields retrieved from the database.
But there will always be an error in the comparison.
When I view the fields in the console.
The first is displayed correctly. (An integer)
But the second is displayed as a hex shape I think. Example: if the retrieved value is'1 ', the value is '0 x6a112f16'.
Here is a portion of the code:
QSqlQuery query11;
query11.prepare("SELECT Seuil_Min FROM Projet.dbo.Produit WHERE Nom=:nom");
query11.bindValue(":nom", ui->comboBox->currentText());
if (query11.exec() && query11.next()) {
ui->textBrowser->setText(query11.value(0).toString());
qint8 min=query11.value(0).toInt();
QSqlQuery query12;
query12.prepare("SELECT Quantité FROM Projet.dbo.Produit WHERE Nom=:nom");
query12.bindValue(":nom", ui->comboBox->currentText());
if (query12.exec() && query12.next()) {
qint8 qt = query12.value(0).toInt();
qDebug()<< qt;
qDebug()<< min;
}
if(qt <= min){
QMessageBox::warning(this,"Information","Vous avez atteint le seuil minimal de ce produit. Un message d'alerte sera envoyé au système centrale !");
}
I'm working on a Qt application that interacts with a SQL database Server.Je want tocompare two fields retrieved from the database.
But there will always be an error in the comparison.
When I view the fields in the console.
The first is displayed correctly. (An integer)
But the second is displayed as a hex shape I think. Example: if the retrieved value is'1 ', the value is '0 x6a112f16'.
Here is a portion of the code:
QSqlQuery query11;
query11.prepare("SELECT Seuil_Min FROM Projet.dbo.Produit WHERE Nom=:nom");
query11.bindValue(":nom", ui->comboBox->currentText());
if (query11.exec() && query11.next()) {
ui->textBrowser->setText(query11.value(0).toString());
qint8 min=query11.value(0).toInt();
QSqlQuery query12;
query12.prepare("SELECT Quantité FROM Projet.dbo.Produit WHERE Nom=:nom");
query12.bindValue(":nom", ui->comboBox->currentText());
if (query12.exec() && query12.next()) {
qint8 qt = query12.value(0).toInt();
qDebug()<< qt;
qDebug()<< min;
}
if(qt <= min){
QMessageBox::warning(this,"Information","Vous avez atteint le seuil minimal de ce produit. Un message d'alerte sera envoyé au système centrale !");
}