Results 1 to 2 of 2

Thread: QMYSQLResult::data: column 1 out of range

  1. #1
    Join Date
    Jun 2014
    Posts
    46
    Thanks
    6
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QMYSQLResult::data: column 1 out of range

    hi to all, I've centos 7 in VM qt 5.7. i am trying to buid a small project, in this i am connecting to mysql database.
    i've this code :-

    Qt Code:
    1. void Sales::on_lineEditQuantity_editingFinished()
    2. {
    3. quantity = ui->lineEditQuantity->text().trimmed().toInt();
    4. int prdnumber = ui->lineEditProductNumber->text().trimmed().toInt();
    5. QString sql = "select rate,stock from tableProductRecords where productID = "+QString::number(prdnumber) +";";
    6.  
    7. query->prepare(sql);
    8. Sales::maxno = setmaxno();
    9. if(query->exec())
    10. {
    11. if(query->next())
    12. {
    13. ui->lineEditRate->setText(query->value(0).toString().trimmed());
    14. ui->lineEditBillNo->setText(QString::number(Sales::maxno));
    15. ui->lineEditTotal->setText(QString::number((query->value(0).toInt()) * quantity));
    16.  
    17. int st = query->value(1).toInt();
    18.  
    19. int stk = st - quantity;//ui->lineEditQuantity->text().trimmed().toInt();
    20. if (stk <= 0)
    21. {
    22. ui->lineEditRate->setText("");
    23. ui->lineEditBillNo->setText("");
    24. ui->lineEditTotal->setText("");
    25. QMessageBox::critical(this, "Sales", "Not enough stock\n available only " + QString::number(st));
    26. return;
    27. }
    28. else
    29. {
    30. ui->lineEditStock->setText(QString::number(stk));
    31.  
    32. sql = "update tableProductRecords set stock = "+ QString::number(stk) + " "+ "where productID = "+ ui->lineEditProductNumber->text().trimmed()+";";
    33. query->prepare(sql);
    34. if(query->exec())
    35. {
    36. QMessageBox::information(this, "Salas", "record updated");
    37. }
    38. }
    39. }
    40. else
    41. {
    42. QMessageBox::critical(this, "on_lineEditQuantity_editingFinished","Error : " + query->lastError().text());
    43. }
    44. }
    45. else
    46. {
    47. QMessageBox::critical(this, "on_lineEditQuantity_editingFinished","Error : " + query->lastError().text());
    48. }
    49. }
    To copy to clipboard, switch view to plain text mode 

    error is that when i run this code this shows two errors :-

    Qt Code:
    1. QMYSQLResult::data: column 1 out of range
    To copy to clipboard, switch view to plain text mode 
    and :-
    not enough space even if here is stock is10;

    not enough space.jpgdatabase.jpg

    how to recover this.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QMYSQLResult::data: column 1 out of range

    Do clean rebuild of your project.
    Single-step through this with your debugger and look at all the values concerned and which line triggers the message.

Similar Threads

  1. rescale to data range when reploting
    By embeddedmz in forum Qwt
    Replies: 1
    Last Post: 19th June 2019, 13:49
  2. Replies: 4
    Last Post: 27th February 2014, 10:42
  3. ODBC driver error QODBCResult::data: column out of range
    By Andrewgaven in forum Qt Programming
    Replies: 6
    Last Post: 16th January 2013, 10:30
  4. Replies: 2
    Last Post: 15th January 2011, 07:07
  5. Replies: 3
    Last Post: 12th June 2008, 12:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.