Results 1 to 19 of 19

Thread: QtSQL - Where is My Database?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default QtSQL - Where is My Database?

    Hello There.

    I Have an Database from 1Blue, with the table "test"

    now i Can connect without problems, but db.tables() says that there are no tables. Why?

    My Code (Zensored)

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    2. db.setHostName("mysql12.1blu.de");
    3. db.setDatabaseName("***********");
    4. db.setUserName("**********");
    5. db.setPassword("**********");
    6. bool ok = db.open();
    7. qDebug() << db.tables();
    8. qDebug() << db.isValid();
    9. qDebug() << db.isOpen();
    To copy to clipboard, switch view to plain text mode 

    And the Return:
    ()
    true
    true

    So why there are no tables? In phpMyAdmin there are tables!

    I hope someone can help me.

    MFG feuerball11

    PS: Sorry for bad english

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

    Default Re: QtSQL - Where is My Database?

    You're using a wrong driver. If you want to connect to a MySQL database, use QMYSQL driver instead of QSQLITE.
    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.


  3. #3
    Join Date
    Jul 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtSQL - Where is My Database?

    Then its not Working. The Programm returns:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
    ()
    false
    false

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

    Default Re: QtSQL - Where is My Database?

    Then you need to install the driver or its dependencies.
    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.


  5. #5
    Join Date
    Jul 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtSQL - Where is My Database?

    Sry for the noob question, but where can i get this driver? must everone install this driver how uses my programm, or only i to compile it?

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

    Default Re: QtSQL - Where is My Database?

    Check if you have the plugin library available. If yes, then probably all you need is to install MySQL client libraries. If no, you'll need to build the plugin
    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.


  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtSQL - Where is My Database?

    If you are using the Qt SDK then you might find this [WIKI]Building the Database Plugins for QtSDK Users[/WIKI] wiki page useful in conjunction with the docs that wysota linked to.

    You will not need to compile the plugin for every user but you will need to deploy the plugin and the MySQL client libraries with your software.

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

    Default Re: QtSQL - Where is My Database?

    AT first. I Using Visual Studio 2008

    I compiled the plugin again and again. but its not working.

    i put qsqlmysqld4.dll and qsqlmysqld4.lib into the folder
    C:\Qt\4.8.2\plugins\sqldrivers

    but qt says only:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL

    can anyone helb me? it cant be so difficult to run this plugin -.-

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtSQL - Where is My Database?

    You do not have to manually copy anything to install the plugin:
    Qt Code:
    1. nmake install
    To copy to clipboard, switch view to plain text mode 
    does that for you.

    The MySQL runtime libraries must be available in the environment (i.e. PATH) of the running program in order to load the plugin.

  10. #10
    Join Date
    Jul 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtSQL - Where is My Database?

    nmake install was sucsesfull, but it doesent work again...

    "Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" geladen, Symbole wurden geladen.
    "Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" entladen.
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL

    .... this is anoying ...

  11. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtSQL - Where is My Database?

    The MySQL runtime libraries must be available in the environment (i.e. PATH) of the running program in order to load the plugin.
    It might be annoying, but you already have the answer. Just like any other piece of code, the Qt MySQL plugin cannot load if it cannot find the libraries it depends on. These libraries are part of MySQL and nothing to do with Qt itself. Windows has a well documented search mechanism for locating dynamically loaded libraries.

    On your development machine you can simply place the MySQL bin directory into the system PATH or the PATH used by your IDE to run the software. (Just like the PostgreSQL libraries must be).

  12. #12
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtSQL - Where is My Database?

    Quote Originally Posted by feuerball11 View Post
    nmake install was sucsesfull, but it doesent work again...

    "Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" geladen, Symbole wurden geladen.
    "Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" entladen.
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL

    .... this is anoying ...
    Sorry i don't read full thread but why are you not use QODBC driver? i use it with MySql and it work fine

Similar Threads

  1. QtService & QtSql
    By acedanans in forum Qt Programming
    Replies: 11
    Last Post: 3rd October 2014, 12:30
  2. QtSQL and databse
    By prophet0 in forum Qt Programming
    Replies: 2
    Last Post: 18th December 2011, 06:22
  3. QtSql or QtSql/ ?
    By szisziszilvi in forum Newbie
    Replies: 3
    Last Post: 8th March 2011, 15:44
  4. about Windows Ado and QtSql
    By lutins in forum General Programming
    Replies: 1
    Last Post: 1st September 2008, 20:04
  5. problem of QtSql
    By cresthong in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2008, 17:48

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.