Results 1 to 1 of 1

Thread: Select and Insert commands failed while writing in to MDB Files

  1. #1
    Join Date
    Feb 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Select and Insert commands failed while writing in to MDB Files

    Hi All,

    I'm a newbie in to this forum. If i posted it in the wrong place, please excuse me. I'm writing a QT program which has to access the MDB file for read and write. When run the program it was connected properly to the database. But while selecting or inserting in the data in to MDB files it was getting failed.

    I'm pasting my code in below:

    #include "msaccess.h"
    #include "ui_msaccess.h"

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

    MSAccess::~MSAccess()
    {
    delete ui;
    }

    void MSAccess::changeEvent(QEvent *e)
    {
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
    ui->retranslateUi(this);
    break;
    default:
    break;
    }
    }
    bool MSAccess::ConnectToDB()
    {
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setHostName("localhost");
    db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=C:/Program Files/NARADA PRODUCTS/MMS/Data/MMS.mdb");
    if (!db.open()) {
    qmb.critical(0, QObject::tr("Database Error"),
    "DataBase Connection Failed");
    return false;
    }
    else
    {
    qmb.information(this,"DataBase Connection","Connection Opened Successfully",QMessageBox::Ok);
    }
    return true;
    }

    void MSAccess::on_bu_get_clicked()
    {
    QString term_id="";
    QString store_id="";
    QStringList Rs;
    QSqlQuery sel_query;

    if(!sel_query.exec("select term_id from pos_terminal where rownum<2"))
    {
    qmb.information(this,"Select query status","select query was Failed",QMessageBox::Ok);
    }

    term_id = sel_query.value(0).toString();
    qmb.information(this,"Terminal Id",term_id,QMessageBox::Ok);
    ui->le_term_id->setText(term_id);

    }

    void MSAccess::on_bu_set_clicked()
    {
    QSqlQuery query("insert into pos_terminal(term_id,store_id) values('12345678')");
    query.exec();
    QSqlDatabase::database().commit();
    }

    When i'm trying to set data then i'm getting this error:

    QODBCResult::exec: Unable to execute statement: " [Microsoft][ODBC Driver Manager] Function sequence error"


    Please tel me the solution for the above problem. It's urgent.

    With Regards,
    Sateesh Lankapalli
    Last edited by sateeshlankapalli; 2nd February 2010 at 08:22.

Similar Threads

  1. Select row in QTableView after insert.
    By fede in forum Newbie
    Replies: 1
    Last Post: 14th April 2009, 15:18
  2. Select multiple files from QFileDialog
    By jiveaxe in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2009, 14:57
  3. QFile resized files gets truncated after writing
    By MaximA in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2008, 17:23
  4. writing CMYK-Files from QImage
    By hilby in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2006, 15:07
  5. [Qt4] writing files
    By patcito in forum Newbie
    Replies: 1
    Last Post: 7th January 2006, 02:41

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.