Results 1 to 4 of 4

Thread: a guide on connecting to mysql database

  1. #1
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default a guide on connecting to mysql database

    hi all i have gone through the internet to try find how to connect to the database but i think there is a library that i need to add to to my simple desktop application, while trying to create a database instance with this line
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

    this (QSqlDatabase) comes out as undeclared identifier and that from my newbie knowledge i think is because their is lack of an essential library, i have checked how to do it in command prompt but the commands are not recognized, can somebody help me with step guide on how to do this?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: a guide on connecting to mysql database

    Make sure your db driver is built, if its not here is how your build it:
    http://qt-project.org/doc/qt-4.8/sql...rted-databases

    And this is how you use it:
    http://qt-project.org/doc/qt-4.8/qsqldatabase.html
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: a guide on connecting to mysql database

    ... and make sure your project file includes the following entry:
    qmake Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: a guide on connecting to mysql database

    thank you all guys. I have work pretty, can query and insert now ope to move to next level by next week, am now trying to do serial port communication let me work on this and if am stack I will get to you guys in this forum helpful, let me do my research first.

Similar Threads

  1. Replies: 3
    Last Post: 9th February 2011, 21:30
  2. Replies: 2
    Last Post: 15th April 2010, 15:59
  3. Problem Wtih Connecting MySQL Database on Windows
    By dummystories in forum Installation and Deployment
    Replies: 25
    Last Post: 29th April 2009, 12:12
  4. Connecting to my database
    By miguel_mark in forum Qt Programming
    Replies: 6
    Last Post: 22nd October 2007, 10:50
  5. connecting to MySQL through it's API
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 20
    Last Post: 31st May 2006, 00:22

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.