Sorry if this is a repost but I couldn't find another post on the subject. I have a need to use Qt and a MS Access database. I have the Qt ODBC plugin built. Now I am trying to access the database. I've done this using Qt and MySQL but I must be doing something wrong here I'm trying to keep it real simple. I wasn't sure what to put for the database name in setDatabaseName(). Do I put the name of the MS Access file?? I'm also not aware of any username/passwords. What am I missing? TIA.
This is the output Im getting:
ODBC:pen() : error opening connection : " [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect"
int main(int argc, char ** argv)
{
qDebug
() <<
"Library Paths " <<
QApplication::libraryPaths() << endl;
// Open connection.
mgDb.setHostName("localhost");
mgDb.setDatabaseName("MissileLogDB_USMTF.mda");
if(mgDb.open() == false)
{
qDebug() << "ODBC::open() : error opening connection : "
<< mgDb.lastError().text() << "\n";
return false;
}
return app.exec();
} // main
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
QSqlDatabase mgDb = QSqlDatabase::addDatabase("QODBC");
qDebug() << "Library Paths " << QApplication::libraryPaths() << endl;
// Open connection.
mgDb.setHostName("localhost");
mgDb.setDatabaseName("MissileLogDB_USMTF.mda");
if(mgDb.open() == false)
{
qDebug() << "ODBC::open() : error opening connection : "
<< mgDb.lastError().text() << "\n";
return false;
}
return app.exec();
} // main
To copy to clipboard, switch view to plain text mode
Bookmarks