Results 1 to 11 of 11

Thread: How to connect Qt with MYSQL??

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to connect Qt with MYSQL??

    How to connect Qt with MYSQL??

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to connect Qt with MYSQL??

    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to connect Qt with MYSQL??

    Anybody there to help me... Am using the following code. It is not connected..

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    2. db.setHostName("localhost");
    3. db.setDatabaseName("Qt");
    4. db.setUserName("root");
    5. db.setPassword("1");
    6. bool ok=false;
    7. ok=db.open();
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 18th March 2011 at 12:49.

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to connect Qt with MYSQL??

    Quote Originally Posted by Gokulnathvc View Post
    It is not connected.
    this means that db.open() returns false?
    The driver is available?

    try with QSqlDatabase::isDriverAvailable
    Qt Code:
    1. bool ok = QSqlDatabase::isDriverAvailable ("QMYSQL");
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  5. #5
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to connect Qt with MYSQL??

    Driver is not available... it returns false.. What should i do now??/

  6. #6
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: How to connect Qt with MYSQL??

    Do you have compiled mysql plugin? Do you have libmysql ?

    What OS are you have?
    Last edited by unit; 18th March 2011 at 13:01.
    Try read Qt documentation before ask stupid question.

  7. #7
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to connect Qt with MYSQL??

    windows xp. I didnt try with the mysql plugins.

  8. #8
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: How to connect Qt with MYSQL??

    You need compile mysql plugin if you want use mysql

    Do you read http://doc.trolltech.com/latest/sql-...rted-databases
    Try read Qt documentation before ask stupid question.

  9. #9
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to connect Qt with MYSQL??

    Actually libmysql file is not there in the Qt installed location

  10. #10
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to connect Qt with MYSQL??

    This has been discussed many times in this forum and the link from 'unit' contains all the information you need, please read it.

    Also, remember that you need to install the MySQL development files (library and include files).
    After building the plugin, the libs will be located in:
    \Qt\<Qt version>\qt\plugins\sqldrivers

    at least that's the location for Qt sdk on XP with mingw.

  11. #11
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: How to connect Qt with MYSQL??

    I don't know if the OP got this issue resolved, but I'd like to add an extra piece of info for anybody else struggling with this. Make sure that you either add the path to MySQL's lib directory to your PATH or drop the libmysql.dll into the same directory as your executable. I spent hours of compiling, recompiling, installing, and uninstalling stuff thinking I had done something wrong, just to find out the DLL dependency was my issue. Hope this saves somebody else the trouble.

Similar Threads

  1. qt connect with mysql in fedora
    By sachinmcajnu in forum Qt Programming
    Replies: 1
    Last Post: 10th March 2011, 19:01
  2. Mysql unknown database, QMYSQL unable to connect
    By lixo1 in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2010, 21:39
  3. Qt connect different MySQL
    By weixj2003ld in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2009, 08:35
  4. How to connect MySQL with QT
    By diego in forum Qt Programming
    Replies: 0
    Last Post: 27th May 2009, 05:34
  5. VS2005+Qt4.2.2:Get a Mysql connect error.HELP!!
    By fengtian.we in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2007, 12:23

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.