Results 1 to 4 of 4

Thread: Drive sql

  1. #1
    Join Date
    Mar 2010
    Location
    Brasília, Brasil
    Posts
    15
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Question Drive sql

    Hi,

    How do I get driver to connect my QT application with a database (preferably MySql) ?
    I really can not find. : /

    Tks.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

  3. #3
    Join Date
    Nov 2010
    Posts
    10
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drive sql

    Here are SQL drivers:
    C:\Qt\2010.05\qt\plugins\sqldrivers\
    You should copy dll files from this folder in to C:\...\project_name-build-desktop\sqldrivers

    You will probably also need some dll files from the folder:
    C:\Qt\2010.05\qt\bin\

    Don't forget to write Qt += core sql into .pro file

    Here is an example:
    Qt Code:
    1. static bool createConnection()
    2. {
    3. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "DatabaseName");
    4. db.setHostName("HostName");
    5. db.setDatabaseName("Database_ODBC_Name");
    6. db.setUserName("user");
    7. db.setPassword("password");
    8. bool status;
    9. status = db.open();
    10.  
    11. return status;
    12. }
    13.  
    14. int main(int argc, char *argv[])
    15. {
    16. QApplication a(argc, argv);
    17.  
    18. if (!createConnection())
    19. {
    20. QMessageBox::information(0, "Error", "Database not openned" );
    21. return 1;
    22. }
    23. else
    24. QMessageBox::information(0, "All fine", "Database openned" );
    25. }
    26.  
    27.  
    28. return a.exec();
    29. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 3rd November 2010 at 15:30. Reason: missing [code] tags

  4. #4
    Join Date
    Mar 2010
    Location
    Brasília, Brasil
    Posts
    15
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Drive sql

    tbscope and Aleksandar thanks (obrigado).

Similar Threads

  1. How to get the Drive letter
    By newb in forum Qt Programming
    Replies: 10
    Last Post: 10th June 2010, 13:59
  2. How to get system drive?
    By Raccoon29 in forum General Programming
    Replies: 2
    Last Post: 23rd November 2008, 14:13
  3. Need help on mount nfs drive in Qt
    By tho97 in forum Qt Programming
    Replies: 3
    Last Post: 28th November 2007, 19:26
  4. problem of how to get drive
    By jyoti in forum General Programming
    Replies: 6
    Last Post: 30th November 2006, 14:18

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.