PDA

View Full Version : how to use ms access files



meozeren
30th July 2009, 14:04
hi all,

i want to access an ms access file and use it, but i can't. i couldn't find any tutorial on this, can anyone help?

thanks
mehmet

spirit
30th July 2009, 16:35
you should use code like this


...
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=" + mdb);
if (!db.open()) {
QMessageBox::critical(this, tr("Error"), db.lastError().text());
return;
}
...

where mdb it is path to mdb file, e.g. "C:/mdbs/my.mdb".