PDA

View Full Version : problem with adding record to the table



bartes19
5th January 2016, 12:20
I have a problem when trying to add a record to the table

screen below



#include "addpatient.h"
#include "ui_addpatient.h"

AddPatient::AddPatient(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddPatient)
{
ui->setupUi(this);
}

void AddPatient::on_addButton_clicked()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "something");
db.setDatabaseName("informix");
if(! db.open())
qDebug() << "exec error" << db.lastError();

QString surname,firstname, address, insurance_number, telephone;

insurance_number=ui->lineEdit_number_id->text().toInt();
surname=ui->lineEdit_surname->text();
firstname=ui->lineEdit_name->text();
address=ui->lineEdit_address->text();
telephone=ui->lineEdit_telephone->text().toInt();

QSqlQuery query(db);

query1.prepare("INSERT INTO pacjent (numer_ubezpieczenia,nazwisko,imie,adres,telefon) "
"VALUES (:numer_ubezpieczenia, :nazwisko, :imie, :adres, :telefon)");

query.bindValue(":numer_ubezpieczenia", insurance_number);
query.bindValue(":nazwisko", surname);
query.bindValue(":imie", firstname);
query.bindValue(":adres", address);
query.bindValue(":telefon", telephone);


if(query.exec())
{
QMessageBox::critical(this,tr("Save"),tr("Saved"));
}
else
{
QMessageBox::critical(this,tr("error:: "),query.lastError().text());
}

}

AddPatient::~AddPatient()
{
delete ui;
//db.close();
}





ERROR:


QODBCResult::exec: Unable to execute statement: "[Informix][Informix ODBC Driver][Informix]Mem [Informix][Informix ODBC Driver][Informix] The curs QODBC3: Unable to execute statement

what's can be wrong ???