Hi , i am trying to connect to an access database (.mdb) using the ODBC driver.
I get the table names but i have trouble making a query
Here is some code
QSqlDatabase mgDb = QSqlDatabase::addDatabase("QODBC","rastrac");
QSqlQuery query(mgDb);
// Open connection.
mgDb.setHostName("localhost");
mgDb.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=rastrac.mdb");
if(!mgDb.open())
{
login->setDbHost( QString("ODBC3:pen() : error opening connection : ") +
mgDb.lastError().text() + "\n");
}
else
login->setDbHost( QString("Success ") );
QStringList list = mgDb.tables(QSql::AllTables);
for(int i=0;i<list.size(); ++i)
{
login->setDbUser(QString("Table names ") + list.at(i)) ;
}
//This is giving me problems
if(!query.exec("SELECT Day FROM VehicleState;"))
...... // error
thank you
Bookmarks