PDA

View Full Version : Connect to Microsoft Access 2010 *.accdb file



FuNkDaDdY
7th November 2010, 10:41
Hi there,

just starting to use Qt for database connectivity. As a test I've got two database files in the root of c:
test.mdb and test.accdb.
Using:



db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={Access};DBQ=c:/test.mdb");


loads up test.mdb without issue. I assumed to open the accdb version all I'd have to do was change the connection string to:


db.setDatabaseName("DRIVER={Microsoft Access Driver (*.accdb)};FIL={MS Access};DBQ=c:/test.accdb");


Unfortunately this results in:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect.



qDebug() << QSqlDatabase::drivers();


returns:
("QSQLITE", "QODBC3", "QODBC")

I'm running a stock Windows 7 install with the test.accdb file a single table simple database created with Microsoft Access 2010. Any ideas?

saa7_go
7th November 2010, 12:54
Try this:

db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DBQ=c:/test.accdb");

FuNkDaDdY
7th November 2010, 13:04
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DBQ=c:/test.accdb");


Sorry, I've tried the above code and that results in exactly the same problem.

saa7_go
7th November 2010, 13:19
Maybe, you need to install Microsoft Access Database Engine 2010 Redistributable (http://www.microsoft.com/downloads/en/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en) and read the instruction about ODBC configuration there.

FuNkDaDdY
7th November 2010, 21:44
Maybe, you need to install Microsoft Access Database Engine 2010 Redistributable (http://www.microsoft.com/downloads/en/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en) and read the instruction about ODBC configuration there.

Alas, I've already tried that. Its made no difference. It looks as though installing Access automatically installs the driver for you. The driver must be there because it loads the .mdb database without issue and I'm assuming its the same driver for both since it says "*.mdb, *.accdb". I even tried the access string microsoft suggested on the driver website (same as what we are using here without the FIL= section). That didn't make any difference either.

jpujolf
7th November 2010, 22:41
Check this (http://connectionstrings.com/access-2007#p127) page. It's useful...

ChrisW67
8th November 2010, 01:54
The forward slash in the file name (i.e. / and not \ ) isn't causing the delightfully inconsistent Windows a problem is it?

FuNkDaDdY
8th November 2010, 08:19
Check this (http://connectionstrings.com/access-2007#p127) page. It's useful...

Thanks, I tried all of these but get the exact same error every time.


The forward slash in the file name (i.e. / and not \ ) isn't causing the delightfully inconsistent Windows a problem is it?

I don't think so. Qt / Windows 7 seems to have no problems loading files with / pathing. Also the c:/test.mdb loads perfectly using that approach.

Just a quick thought, If I make up a random file name and try that (eg I_dont_exist.accdb) I still get the same error so is it possible that its not finding the file at all for some reason? Perhaps accdb files can't be targeted with absolute paths or something? Clutching at straws here now!

wib
10th November 2010, 13:08
please check:
http://www.microsoft.com/downloads/en/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en

FuNkDaDdY
10th November 2010, 22:23
please check:
http://www.microsoft.com/downloads/en/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en

This has already been discussed in this thread.

followingsun
24th July 2013, 10:38
did you linked *.accdb successfully?

edwards142
26th April 2018, 08:43
After reading complete of your issue I come to know that your issue is related to mine i.e [Microsoft][ODBC Microsoft Access Driver] Cannot Update. Database Or Object Is Read-Only . I encountered this issue few months ago and when I look for the fixes I got this helpful post which contain the manual fixes to resolve this issue. I tried it and easily been able to resolve it. So, check that out….i hope you found it helpful.

Read more:


http://www.accessrepairnrecovery.com/blog/fix-odbc-microsoft-access-driver-cannot-update-database-object-is-read-only-error
:):rolleyes: