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 .mdb or .accdb files?
QtWS25 Last Chance

How to create .mdb or .accdb files?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 273 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.
  • M Offline
    M Offline
    manikanta27
    wrote on last edited by
    #1

    I'm working with Qt Creator 4.14.2. My application is based on MSVC2019, 32 bit.
    I need help creating an mdb or accdb file during runtime of an application. I found two threads on this forum

    1. https://forum.qt.io/topic/3990/how-to-create-a-ms-access-mdb-file-by-qt
    2. https://forum.qt.io/topic/58929/how-to-create-a-new-xx-mdb-ms-access-file-file-using-qt

    I deduced that it is not easier to create Access files in runtime or not possible to create. Is it still like that? Above threads dated back to 2011 and 2015.

    I have used QFile which is only creating a text file with accdb extension.

    Some external posts say that as soon as db.open() is called, Qt creates the file automatically. It is not happening in my case. Am I missing anything in my Qt installation? What should be installed via Qt Maintenance tool if I want file to be created automatically?

    Regards

    1 Reply Last reply
    0
    • M manikanta27

      @VRonin
      Thanks for the suggestion. I'd certainly follow that. Can you help me with a sample code to copy a file to some other location and keep the original as is?
      And also can I have multiple db connections open during runtime?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @manikanta27 said in How to create .mdb or .accdb files?:

      Can you help me with a sample code to copy a file to some other location

      See https://doc.qt.io/qt-5/qfile.html#copy-1
      Yes, you can have more than one connection to a db at runtime. See https://doc.qt.io/qt-5/qsqldatabase.html, you can give each connection its own name.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #2

        The Qt ODBC driver has no problem managing ms access files but it can't create them out of the box. What you could do is use MS Access to create a blank database and then add that to the resources of your program. When you need to create a new DB, then, you would just copy that stored file.

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        5
        • M Offline
          M Offline
          manikanta27
          wrote on last edited by
          #3

          @VRonin
          Thanks for the suggestion. I'd certainly follow that. Can you help me with a sample code to copy a file to some other location and keep the original as is?
          And also can I have multiple db connections open during runtime?

          jsulmJ 1 Reply Last reply
          0
          • M manikanta27

            @VRonin
            Thanks for the suggestion. I'd certainly follow that. Can you help me with a sample code to copy a file to some other location and keep the original as is?
            And also can I have multiple db connections open during runtime?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @manikanta27 said in How to create .mdb or .accdb files?:

            Can you help me with a sample code to copy a file to some other location

            See https://doc.qt.io/qt-5/qfile.html#copy-1
            Yes, you can have more than one connection to a db at runtime. See https://doc.qt.io/qt-5/qsqldatabase.html, you can give each connection its own name.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            3

            • Login

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