Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to create a MS access mdb file by QT

How to create a MS access mdb file by QT

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 5.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zjuboy
    wrote on last edited by
    #1

    really appreciate!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jstaniek
      wrote on last edited by
      #2

      Hi,
      In general you can't. You can use windows-only facilities like MS ADO components and glue your code with your Qt application but this won't be portable across OSes, i.e. would be done against the Qt principles. While still legal that's not what I decided to do for "supporting" MDB files. I, within the Kexi Project (http://kexi-project.org, http://community.kde.org/Kexi) used and a bit extended the MDB Tools open source project in order to get read only access to the MS Access files. This just enables an escape scenario so your data is eventually yours (but not your forms or even queries, handling them is only planned but possible after massive reverse engineering).

      So I recommend to review your requirements; it may be that you can stick with SQLite (which is used by Kexi by default) or even server database like MySQL or PostgreSQL - then you can use any of them directly with Qt (its QtSQL module).

      Just please note that creating new databases is not supported by the QtSQL API. You have to know how to do it (call single "open" function in SQLite or do some more calls in case of MySQL or PostgreSQL). If you expect to have all this done for you automagically, I've created special library extending Qt exactly for this, Predicate (http://community.kde.org/Predicate). It was a part of Kexi, now it's not technically dependent on KDE or Kexi. If you think it's all nice and shiny, now the bad news: it should be available for general use by the end of 2011.

      PS: I do not think using ODBC would help you. You have to get access (pun not intended ;)) to a working Access instance anyway.

      regards, Jarosław Staniek

      Certified Qt Specialist & Ambassador
      Kexi: http://kexi-project.org
      Calligra: http://calligra.org
      Qt for Tizen

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dialingo
        wrote on last edited by
        #3

        If MS Access is installed in parallel your Qt application can use COM to connect to MS Access and call its methods.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          What I do, is use ODBC to access MS Access files. That works well, although speed (especially for writing) could be better.

          For creating an empty MDB file, there are two approaches. First of all, you can create one using a little bit of ActiveX. What you can also do, and that gives you the opportunity to prepare your data structure ahead of time if your app allows for that, is just to compile an empty .mdb file into your application as a resource, and copy that out to disk when you need it. I do that in my application, and that works just fine.

          jstaniek is right that Qt's API for manipulating databases is a bit lacking here and there. I have created an extension to this API to fix this where possible, but in the end his new Predicate framework is probably the better approach. However, seeing that that will still take time to mature, perhaps you can use it to build something that works now. The Access driver (building on ODBC) is actually the most mature and tested one.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved