Results 1 to 1 of 1

Thread: problem with adding record to the table

  1. #1
    Join Date
    Jan 2016
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default problem with adding record to the table

    I have a problem when trying to add a record to the table

    screen below

    Qt Code:
    1. #include "addpatient.h"
    2. #include "ui_addpatient.h"
    3.  
    4. AddPatient::AddPatient(QWidget *parent) :
    5. QDialog(parent),
    6. ui(new Ui::AddPatient)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. void AddPatient::on_addButton_clicked()
    12. {
    13. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "something");
    14. db.setDatabaseName("informix");
    15. if(! db.open())
    16. qDebug() << "exec error" << db.lastError();
    17.  
    18. QString surname,firstname, address, insurance_number, telephone;
    19.  
    20. insurance_number=ui->lineEdit_number_id->text().toInt();
    21. surname=ui->lineEdit_surname->text();
    22. firstname=ui->lineEdit_name->text();
    23. address=ui->lineEdit_address->text();
    24. telephone=ui->lineEdit_telephone->text().toInt();
    25.  
    26. QSqlQuery query(db);
    27.  
    28. query1.prepare("INSERT INTO pacjent (numer_ubezpieczenia,nazwisko,imie,adres,telefon) "
    29. "VALUES (:numer_ubezpieczenia, :nazwisko, :imie, :adres, :telefon)");
    30.  
    31. query.bindValue(":numer_ubezpieczenia", insurance_number);
    32. query.bindValue(":nazwisko", surname);
    33. query.bindValue(":imie", firstname);
    34. query.bindValue(":adres", address);
    35. query.bindValue(":telefon", telephone);
    36.  
    37.  
    38. if(query.exec())
    39. {
    40. QMessageBox::critical(this,tr("Save"),tr("Saved"));
    41. }
    42. else
    43. {
    44. QMessageBox::critical(this,tr("error:: "),query.lastError().text());
    45. }
    46.  
    47. }
    48.  
    49. AddPatient::~AddPatient()
    50. {
    51. delete ui;
    52. //db.close();
    53. }
    To copy to clipboard, switch view to plain text mode 


    ERROR:

    Qt Code:
    1. QODBCResult::exec: Unable to execute statement: "[Informix][Informix ODBC Driver][Informix]Mem [Informix][Informix ODBC Driver][Informix] The curs QODBC3: Unable to execute statement
    To copy to clipboard, switch view to plain text mode 

    what's can be wrong ???
    Attached Images Attached Images
    Last edited by bartes19; 5th January 2016 at 12:32.

Similar Threads

  1. Adding new record to database from QDataWidgetMapper
    By naptizaN in forum Qt Programming
    Replies: 4
    Last Post: 15th July 2012, 13:19
  2. Replies: 2
    Last Post: 25th June 2012, 10:54
  3. Replies: 4
    Last Post: 10th May 2011, 12:19
  4. Replies: 3
    Last Post: 4th August 2010, 18:51
  5. Not corect record pos in data table after update
    By zlatko in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2006, 16:51

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.