Results 1 to 1 of 1

Thread: Problems with QODBC and MySQL

  1. #1
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QODBC and MySQL

    So I have MySQL running and want to interface with it through ODBC, I have ODBC for mysql installed and configured under my windows data sources (using Windows 7 btw)
    when I try to run the following code:
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    2.  
    3. db.setHostName("localhost");
    4. db.setDatabaseName("test");
    5. db.setUserName("root");
    6. db.setPort(3306);
    7. db.setPassword("xxxxxx");
    8. qDebug() << db.isValid();
    9. if (!db.open()) cout << "Failed to connect to root mysql admin";
    10. //!db.open() always returns true so something is wrong
    To copy to clipboard, switch view to plain text mode 

    I get
    Qt Code:
    1. "Failed to connect to root mysql admin"
    To copy to clipboard, switch view to plain text mode 

    I have also tried running
    Qt Code:
    1. qDebug() << << QSqlDatabase::drivers();
    To copy to clipboard, switch view to plain text mode 

    and it returns <QSQLITE, QODBC, QODBC3>

    What could be wrong?


    Added after 1 22 minutes:


    nevermind, the PC am using had mysql for x64, but my connector was for x86, so there was an architecture mismatch, simply removing the x86 connector and installing the x64 one fixed these issues.
    Last edited by crazymonkey; 25th April 2011 at 12:34.

Similar Threads

  1. Replies: 0
    Last Post: 27th February 2011, 14:39
  2. Problems with MySQL on Ubuntu
    By neoclaw in forum Qt Programming
    Replies: 3
    Last Post: 21st June 2010, 02:26
  3. QODBC, QSqlTableModel, and submit problems
    By darkadept in forum Qt Programming
    Replies: 3
    Last Post: 18th May 2008, 12:46
  4. Problems with Qt 4.3.4 and MySql
    By Headhunter_X in forum Installation and Deployment
    Replies: 9
    Last Post: 19th March 2008, 06:17
  5. Mysql drivers install problems
    By cyberboy in forum Qt Programming
    Replies: 20
    Last Post: 2nd February 2008, 14:11

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
  •  
Qt is a trademark of The Qt Company.