Hi guys.
I have a database (.mdb) and I connect to it from my QT application. I do not have problems to read the data but when I save it, I want to do it through a transaction and I can not because I'm having an error. I paste how I open the connection and how I launch the transaction:
The connection:
QString strPathDDBB
="DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=" + QCoreApplication::applicationDirPath() + "/galibo.mdb";
m_db.setDatabaseName(strPathDDBB);
if (!m_db.open()) {
}
m_db = QSqlDatabase::addDatabase("QODBC");
QString strPathDDBB="DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=" + QCoreApplication::applicationDirPath() + "/galibo.mdb";
m_db.setDatabaseName(strPathDDBB);
if (!m_db.open()) {
QMessageBox::critical(0, QObject::tr("Database Error"), m_db.lastError().text());
}
To copy to clipboard, switch view to plain text mode
The transaction:
bool feature
= m_db.
driver()->hasFeature
(QSqlDriver::Transactions);
if (!m_db.transaction())
{
error = "An error occurred while creating the transaction in the database\n";
error += m_db.lastError().text();
return false;
}
bool feature = m_db.driver()->hasFeature(QSqlDriver::Transactions);
if (!m_db.transaction())
{
error = "An error occurred while creating the transaction in the database\n";
error += m_db.lastError().text();
return false;
}
To copy to clipboard, switch view to plain text mode
The feature variable returns true and the text error is "[Microsoft] [Microsoft Access ODBC Driver] Unable to define attribute now QODBC3: Unable to disable autocommit"
Any ideas?
Bookmarks