You are not logged in.

1

Wednesday, February 22nd 2012, 8:54pm

Problem QT : Comparison from the base

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:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 !");     }

2

Wednesday, February 22nd 2012, 10:08pm

great. So what is your question?
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Wednesday, February 22nd 2012, 10:14pm

the comparison didn't work. What shall i do ?

4

Thursday, February 23rd 2012, 1:01pm

check that your database values are actually correct.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.