PDA

View Full Version : how to connect to a microsoft access database?



mismael85
6th March 2008, 23:34
hello evrybody,
i am writing a program that should connect to a microsoft access
what should i do to connect to such database?
note that i wrote this code:


QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=book.mdb");
if(db.open())
QMessageBox::warning(this, "opened","successful");

and every thing works fine and the program is compiled successfully but
when i execute the program the message that indicate to the database is opend does not appear it means that the database can not be opened
should i do some thing to the windows OS or install some thing to let me
connect to ms Access database???
thank you...

mismael85
7th March 2008, 08:18
i executed this function

QSqlDatabase::isDriverAvailable("QODBC")
and it returns false
it means that the driver does not exist!!!

jpn
7th March 2008, 08:20
See How to Build the ODBC Plugin on Windows (http://doc.trolltech.com/4.3/sql-driver.html#how-to-build-the-odbc-plugin-on-windows).

mismael85
7th March 2008, 10:25
i built it, thank you i will keep going on my project . i am sure i will face some problems
and i will ask you again .
please be patient with me.
excuse me.