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. MySQL with QT
Forum Updated to NodeBB v4.3 + New Features

MySQL with QT

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 4.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.
  • A Offline
    A Offline
    awood969
    wrote on last edited by
    #1

    Hi guys,

    I'm after a little support in connecting QT up to a MySQL database. I am going to need my application to contact both a remote and local database.

    I have done some searching online however it all seems a little old with many results being from back in the days of QT3 which are of course dead now.

    I do not want to use any crazy C Connector ports from C as these seem to be proving more trouble than they are worth. I am assuming however that both MySQL and QT talk the same talk on some form of ODBC connection.

    If somebody could please help me get started with this, nothing fancy just connections and standard SQL Queries, no stored procedures or anything fancy like that.

    Thanks
    Andrew

    I'm only asking as I'm stupid :-)

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tbscope
      wrote on last edited by
      #2

      Did you already read the documentation?
      http://doc.qt.nokia.com/4.7/qt-sql.html

      If so, can you be more specific with your question?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        You must compile Qt with MySql support and than follow the Qt documentation.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          [quote author="Luca" date="1296632628"]You must compile Qt with MySql support and than follow the Qt documentation.[/quote]

          The SQL plugins can be added later on, no need to completely rebuild a binary installation for Qt.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            awood969
            wrote on last edited by
            #5

            Thank you tbscope - I was looking for a specific QMySQL class like they have a QSQLLite class. However I notice the pages you gave me include a list of supported drivers.

            Thank You (& forgive my stupidity :-P)
            Andrew

            I'm only asking as I'm stupid :-)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              awood969
              wrote on last edited by
              #6

              Oh nope...Just looking now it says the MySQL driver is supported by default and it seems silly ridiculous to get it on the system having to install lots of programs cluttering up my drives.

              Does anybody have a "pre-built" MySQL5.0 or 5.1 driver already built?

              Thanks
              Andrew

              I'm only asking as I'm stupid :-)

              1 Reply Last reply
              0
              • J Offline
                J Offline
                js_dev
                wrote on last edited by
                #7

                If you want to use the Qt database driver for MYSQL, I guess all you have to is something like this:

                @
                QSqlDatabase myDb = QSqlDatabase::addDatabase("QMYSQL","DEFAULT");
                myDb.setDatabaseName( [add your file name with path here] );
                if(!myDb.open())
                {
                ... your code
                }
                @

                Don't be afraid of perfection, you will never reach it.
                (Salvator Dali)

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  awood969
                  wrote on last edited by
                  #8

                  This what I'm currently getting running that, from my Application Output;

                  @Starting D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe...
                  QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
                  D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe exited with code -1073741819@

                  And when I run the ODBC driver I just get;

                  @Starting D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe...
                  D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe exited with code -1073741819@

                  I'm only asking as I'm stupid :-)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    awood969
                    wrote on last edited by
                    #9

                    Never mind, all sorted.

                    Problems were occuring as I was using Windows Powershell to try and build the driver but actually there was a QT Command Prompt which did the job lovely.

                    Thanks Guys
                    Andrew

                    I'm only asking as I'm stupid :-)

                    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