QSqlDatabase db;
db = db.addDatabase("QODBC");
QString path("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DBQ=D:\\QT\\first\\build-Thread-Desktop_Qt_5_9_0_MSVC2013_64bit-Debug\\test.mdb");
db.setDatabaseName(path);
if (db.open())
{
// success!
qDebug() << "Success";
}
else{
qDebug() << "Errror!";
qDebug() << db.lastError().text();
QSqlError error = db.lastError().text();
QMessageBox::information(NULL,"提示",error.text(),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes);
db.close();
}