Results 1 to 14 of 14

Thread: Qt in windows and mysql !!!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt - Windows - MySQL

    I am having trouble connecting from Qt (Windows) to my database.

    I am using MySQL and the server is running. With some GUI clients I am connecting to the database, but when I try to connect from Qt, I just cannot.

    I have included "#include <QtSql>" in my .cpp
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    2. db.setHostName("localhost");
    3. db.setDatabaseName("testdata");
    4. db.setUserName("test");
    5. db.setPassword("password");
    6. bool ok = db.open();
    7. if(ok)
    8. textBrowser->append("Conection to DATABASE");
    9. else
    10. textBrowser->append("error to DATABASE");
    To copy to clipboard, switch view to plain text mode 


    I have also included "QT += sql" to my .pro

    I can compile and run the code perfectly, there is no errors in it. But, but I guess that there is no connection, because I always end up printing the "error to Database" message on the screen.


    Help please ?
    Last edited by probine; 7th December 2006 at 15:39.

Similar Threads

  1. Embedded Mysql Windows Qt4.1
    By benguela in forum Qt Programming
    Replies: 7
    Last Post: 17th January 2007, 00:13
  2. Connection to MySQL - windows
    By Peter34 in forum Qt Programming
    Replies: 18
    Last Post: 30th October 2006, 18:54
  3. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 09:19
  4. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38
  5. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 20:22

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.