Results 1 to 12 of 12

Thread: Connect to Microsoft Access 2010 *.accdb file

  1. #1
    Join Date
    Nov 2010
    Posts
    10
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Connect to Microsoft Access 2010 *.accdb file

    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:

    Qt Code:
    1. db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={Access};DBQ=c:/test.mdb");
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. db.setDatabaseName("DRIVER={Microsoft Access Driver (*.accdb)};FIL={MS Access};DBQ=c:/test.accdb");
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. qDebug() << QSqlDatabase::drivers();
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    Try this:
    Qt Code:
    1. db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DBQ=c:/test.accdb");
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2010
    Posts
    10
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    Qt Code:
    1. db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DBQ=c:/test.accdb");
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    Maybe, you need to install Microsoft Access Database Engine 2010 Redistributable and read the instruction about ODBC configuration there.

  5. #5
    Join Date
    Nov 2010
    Posts
    10
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    Quote Originally Posted by saa7_go View Post
    Maybe, you need to install Microsoft Access Database Engine 2010 Redistributable 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.

  6. #6
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    Check this page. It's useful...

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,551
    Thanks
    13
    Thanked 1,579 Times in 1,508 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Connect to Microsoft Access 2010 *.accdb file

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

  8. #8
    Join Date
    Nov 2010
    Posts
    10
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    Quote Originally Posted by jpujolf View Post
    Check this page. It's useful...
    Thanks, I tried all of these but get the exact same error every time.

    Quote Originally Posted by ChrisW67 View Post
    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!

  9. #9
    Join Date
    Nov 2010
    Posts
    1

    Default Re: Connect to Microsoft Access 2010 *.accdb file


  10. #10
    Join Date
    Nov 2010
    Posts
    10
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    Quote Originally Posted by wib View Post
    This has already been discussed in this thread.

  11. #11
    Join Date
    May 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connect to Microsoft Access 2010 *.accdb file

    did you linked *.accdb successfully?

  12. #12
    Join Date
    Apr 2018
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Re: Connect to Microsoft Access 2010 *.accdb file

    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:


Similar Threads

  1. Replies: 13
    Last Post: 2nd June 2016, 17:51
  2. HowTo get work Microsoft VS 2010 and Qt Visual Studio Add-in?
    By NewLegend in forum Installation and Deployment
    Replies: 15
    Last Post: 17th October 2010, 18:15
  3. Replies: 10
    Last Post: 30th September 2010, 06:16
  4. Replies: 1
    Last Post: 20th September 2010, 16:49
  5. how to connect to a microsoft access database?
    By mismael85 in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 09:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.