Results 1 to 6 of 6

Thread: SqlDriverPlugin

  1. #1
    Join Date
    Feb 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default SqlDriverPlugin

    Hello folks,

    I've installed the mysql driver plugin on winXP after this guide:
    http://wiki.qtcentre.org/index.php?t...ws_using_MinGW

    After this installation I've cleaned the plug-in cache. But it dosn't work. I have allways the error, driver not loaded.

    Here is the code for the mysql connection:
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    2. db.setHostName(hostnameLineEdit->text());
    3. db.setUserName(usernameLineEdit->text());
    4. db.setPassword(passwordLineEdit->text());
    5. db.setDatabaseName(dbnameLineEdit->text());
    6.  
    7. if (!db.open())
    8. QMessageBox::critical(0, tr("Error"), QString("The error:\n%1").arg(db.lastError().text()));
    To copy to clipboard, switch view to plain text mode 

    Under linux all works fine. Whats the problem with windows?

    so long
    jd
    The most difficult in the world is to live in it

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SqlDriverPlugin

    Have you tried opening the compiled plugin in Dependency Walker?
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    jd (16th May 2008)

  4. #3
    Join Date
    Feb 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: SqlDriverPlugin

    Yes, I can't see any problems.

    I've wrote a small application with database support:

    test.h
    Qt Code:
    1. #ifndef TEST_H_
    2. #define TEST_H_
    3. #include <QPushButton>
    4. class MyClass : public QObject
    5. {
    6. Q_OBJECT
    7. public:
    8. MyClass();
    9. QPushButton *myButton;
    10. public slots:
    11. void mySlot();
    12. };
    13.  
    14. #endif /*TEST_H_*/
    To copy to clipboard, switch view to plain text mode 

    test.cpp
    Qt Code:
    1. #include <QtGui>
    2. #include "test.h"
    3. #include <QtSql>
    4.  
    5. MyClass::MyClass()
    6. {
    7. myButton = new QPushButton;
    8. connect(myButton, SIGNAL(clicked()),
    9. this, SLOT(mySlot()));
    10. myButton->setText(tr("Klick mich!"));
    11. myButton->show();
    12. }
    13.  
    14. void MyClass::mySlot()
    15. {
    16. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    17. db.setHostName("192.168.2.229");
    18. db.setUserName("qfinancialoffice");
    19. db.setPassword("test");
    20. db.setDatabaseName("qfinancialoffice");
    21. if (!db.open())
    22. QMessageBox::critical(0, tr("Error"), QString("The error:\n%1").arg(db.lastError().text()));
    23. else
    24. QMessageBox::critical(0, tr("OK"), QString("OK"));
    25. }
    To copy to clipboard, switch view to plain text mode 

    This works fine! (Win & Linux)

    In my other and bigger application I get the error driver not loaded. I can't locate the problem, but under Linux all works fine. The code for the database connection is the same there is no wrapper class or anything else. Why exits the problem under windows only. How can I locate the problem? I have not enough experience with windows to do this.
    The most difficult in the world is to live in it

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SqlDriverPlugin

    Are you experiencing the problem on the development machine or while deploying? Do you have multiple Qt installations in Windows?
    J-P Nurmi

  6. #5
    Join Date
    Feb 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: SqlDriverPlugin

    No, only 4.3.4.

    I've no idea to locate the problem. I think there is a big mistake in my code. Now, I'll debug the code to locate the problem. For Example:

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "MainWindow/MainWindow.h"
    3. #include "LoginDialog/LoginDialog.h"
    4. #include "Settings/Settings.h"
    5. #include "StartupWizard/StartupWizard.h"
    6. #include <QtSql>
    7.  
    8. int main(int argc, char *argv[]) {
    9. QApplication app(argc, argv);
    10. QCoreApplication::setOrganizationName("NORO-Automaten");
    11. QCoreApplication::setOrganizationDomain("http://www.noro.de");
    12. QCoreApplication::setApplicationName("QFinancialOffice");
    13.  
    14. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    15. db.setHostName("192.168.2.229");
    16. db.setUserName("qfinancialoffice");
    17. db.setPassword("test");
    18. db.setDatabaseName("qfinancialoffice");
    19. if (!db.open())
    20. QMessageBox::critical(0, QString("Error"), QString("The error:\n%1").arg(db.lastError().text()));
    21. else
    22. QMessageBox::critical(0, QString("OK"), QString("OK"));
    23.  
    24. CSettings *configure = new CSettings;
    25.  
    26. if (configure->settings.firstrun) {
    27. QMessageBox::information(0, QObject::tr("Erster Start"), QObject::tr("Dies ist der erste Start von <b>QFinancialOffice</b>.\nAls erstes muessen Sie <b>QFinancialOffice</b> konfigurieren."));
    28. ClassWizard *wizard = new ClassWizard;
    29. if (wizard->exec() == ClassWizard::Accepted) {
    30. QMessageBox::information(0, QObject::tr("Neustart"), QObject::tr("QFinancialOffice wird jetzt neu gestartet."));
    31. QProcess process;
    32. process.startDetached(QApplication::applicationFilePath());
    33. process.waitForStarted();
    34. }
    35.  
    36. delete configure;
    37. return 1;
    38. } else {
    39. CLoginDialog *login = new CLoginDialog;
    40. if (login->exec() == CLoginDialog::Accepted) {
    41. CMainWindow *window = new CMainWindow;
    42. window->show();
    43. } else {
    44. QMessageBox::critical(0, QString("Fehler"), QString("Der Login war nicht erfolgreich\n Programm kann nicht gestartet werden.\n"));
    45. return 1;
    46. }
    47. }
    48.  
    49. app.exec();
    50. }
    To copy to clipboard, switch view to plain text mode 

    You can see, at first I'll test my local database connection, this test fails on windows but not on linux. In my test program there is the same test code and it works.

    I don't know, but can it be, that I have an memory problem?

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    To copy to clipboard, switch view to plain text mode 

    This object will be saved on the stack. If my stack is full I had an undefined problem or not?

    The problem is unbelievabl.
    The most difficult in the world is to live in it

  7. #6
    Join Date
    Feb 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: SqlDriverPlugin

    Ok, now I've sloved the problem. I've upgraded my Qt version to 4.4.0 and all works fine. Thanks for help.

    so long
    jd
    The most difficult in the world is to live in it

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.