Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Parsing .mdb File in Qt4
Qt 6.12 LTS is out! See what's new in the release blog

Parsing .mdb File in Qt4

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 14.4k Views 1 Watching
  • 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.
  • V Offline
    V Offline
    vezprog
    wrote on last edited by
    #5

    Thank you for the helpful sample code, I will take a look and see if I can make some progress.

    Thanks again!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #6

      I apologize for the double post, for some reason I cannot get your code snipet to work. I have the odbc driver installed on linux, and i have the QtSql/SqlDatabae, QtSql/QODBCDriver incuded. I get the error when I try to run "sql.h: no such file or directory".

      @

      #include <QtCore>
      #include <QtSql/QSqlDatabase>
      #include <QtSql/QSqlQuery>
      #include <QtSql/QODBCDriver>
      #include <QtSql/qsql.h>
      #include "globals.h"
      #include "graph.h"
      #include "graphscrollbar.h"
      #include "buttonheader.h"
      #include "buttonsidebar.h"
      #include "mainwindow.h"
      #include "ui_mainwindow.h"

      // file prototype
      void connectODBCdatabase(QString selectedfile);

      void connectODBCdatabase(QString selectedfile)
      {
      // build database string
      QString filePath = "DRIVER={Driver do Microsoft Access (*.mdb)};FIL={CONN_NAME};DBQ=";
      filePath.append(selectedfile);

      // create database
      QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "odbc");
      db.setDatabaseName(filePath);
      
      // get data from .mdb file
      QSqlQuery query(db);
      query.exec("SELECT * FROM TABLE tablename;"&#41;;
      

      }

      @

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

        On linux, you are probably out of luck. AFAIK, there is no ODBC driver for mdb on non-windows systems. If you are on linux, I would strongly encourage you to see if there isn't a way to switch to a different database format.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vezprog
          wrote on last edited by
          #8

          Unfortunately there is a separate software suit that creates the .mdb files, which is out of my control at the moment. I thought the unixODBC driver allows the user to communicate to that specific database format, which in turn, should allow me to access the database file correct? I guess my understanding on .mdb files is vague though...

          I could convert the file to a comma delimited file using tools already available in the Linux world, but lets be real here, that's unacceptable to my standards :) I would like to automate this process.

          There's gotta be a way to connect using SQL query's to the file.

          I thank you for your insight, I will keep searching around.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #9

            [quote author="Andre" date="1313780603"]On linux, you are probably out of luck. AFAIK, there is no ODBC driver for mdb on non-windows systems.[/quote]
            yes, does exist, but it is paid http://www.easysoft.com/products/data_access/odbc-access-driver/

            You can use mdb tools to extract the data into a csv and parse as plain text (http://mdbtools.sourceforge.net/)

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vezprog
              wrote on last edited by
              #10

              yeah, that was my "easy way out" using mdb tools. I fooled around with it yesterday, and was satisfied, yet I still would like to not have to convert the file. I will check out easysoft. Thank you.

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

                ODBC in and off itself does not allow you to interact with any database. It needs drivers to do the actual work. -AFAIK, there is no ODBC driver for .mdb files on unix, but I may be off there. I never found something that worked.-

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

                  [quote author="Wagner Reck" date="1313781485"]
                  [quote author="Andre" date="1313780603"]On linux, you are probably out of luck. AFAIK, there is no ODBC driver for mdb on non-windows systems.[/quote]
                  yes, does exist, but it is paid http://www.easysoft.com/products/data_access/odbc-access-driver/

                  You can use mdb tools to extract the data into a csv and parse as plain text (http://mdbtools.sourceforge.net/)

                  [/quote]

                  I stand corrected. Thanks for the information!

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vezprog
                    wrote on last edited by
                    #13

                    yeah, that was my "easy way out" using mdb tools. I fooled around with it yesterday, and was satisfied, yet I still would like to not have to convert the file. I will check out easysoft, yet its quite a hefty price unfortunately. Thank you though.

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

                      Not sure if this is an option, but...
                      Could you keep the actual files on a windows machine and connect to that machine over the network? If so, than it should be doable to either expose the ODBC data connection to the network, or perhaps create a Qt based server that does the actual data querying for its connected (linux) clients.

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        vezprog
                        wrote on last edited by
                        #15

                        Now you got my thinkin.

                        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
                        • Unsolved