QSQLDriver and Microsoft Access: Crash on insert statement?
Unsolved
General and Desktop
-
Whenever I execute an insert statement from QtC++ I get an unhandled exception from the ODBC driver resulting in a crash. :frowning: Code is this:
DBAccess::m_db = QSqlDatabase::addDatabase("QODBC"); DBAccess::m_db.setHostName("localhost"); DBAccess::m_db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DBQ=" + elLoc + "");//C:\\Dev\\AccessDB\\SVLearn_MNIST.accdb"); DBAccess::m_db.setConnectOptions("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3"); bool ok = DBAccess::m_db.open(); qDebug() << m_db.driverName(); if(ok) qDebug()<<"ok"; else qDebug()<<"not ok"<< m_db.lastError().text();
Which is successful (ok)
query.prepare("INSERT INTO t_MNIST ( str64Data, blnTest, intLabel, intGroup ) VALUES ('Get a life', False, 0, 0);"); if (!query.next()) { qDebug() << (query).lastError(); LOG_FAILED_QUERY(query); return; }
Which crashes with a hidden exception thrown.
-
@MGirgis
Show code --- we still don't know for example where you declaredquery
,m_db
looks like a member variable, yetDBAccess::m_db
looksstatic
.Better still, run this code under debugger. Look at the stack trace at the exception. I don't know which "that line" is among the lines you have.
Having said that, I know nothing about QSQLDriver and Microsoft Access.