Results 1 to 3 of 3

Thread: Cannot load SQL driver in Visual C++ (but works in QtCreator)

  1. #1
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Cannot load SQL driver in Visual C++ (but works in QtCreator)

    I have a QT application that requires the MySql driver. I have both a .pro file to compile the app with QtCreator and a .vcproj for Visual C++ 2008 Express. The code is identical and it compiles without a hitch, but the executable created by Visual C++ Express gives me the following output and refuses to load any driver/plugin:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers:

    I used QCoreApplication to identify the location where the plugins are and it seems that both executables have the same path, so they should both see the plugins. One does, and the other doesn't.

    The code is standard.

    Qt Code:
    1. db = QSqlDatabase::addDatabase("QMYSQL");
    2. db.setHostName("localhost");
    3. db.setPort(3306);
    4. db.setDatabaseName("dbase");
    5. db.setUserName("user");
    6. db.setPassword("pwd");
    7. bool ok = db.open();
    To copy to clipboard, switch view to plain text mode 

    The same thing happens with the SqlBrowser sample that came with QT, so I don't think the code is the problem.

  2. #2
    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: Cannot load SQL driver in Visual C++ (but works in QtCreator)

    see if this thread helps:
    http://www.qtcentre.org/forum/f-inst...lem-25071.html

    are you running from IDE or from the cmd line?

    make sure to create the plugins directory and have the mysql client dll in your path

  3. #3
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot load SQL driver in Visual C++ (but works in QtCreator)

    For anyone else who bumped into this problem I have to say this - it is much easier to use one of the packages containing QT pre-built binaries for Visual C++ than trying to build it yourself. And the Qt driver (the 4.3 version at least) is awfully hard to get to work, especially when deploying your application (on some machines it works like a charm but on others it can't find the driver, using the same code and binaries) and is not worth the trouble, you are much better off using a dedicated MySql library.

Similar Threads

  1. SQL driver load problem
    By vieraci in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2009, 15:59
  2. Qt configure with msvc.net
    By jivanr in forum Installation and Deployment
    Replies: 1
    Last Post: 11th June 2007, 09:17

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.