Results 1 to 4 of 4

Thread: SQL Connection Problem

  1. #1
    Join Date
    Oct 2009
    Location
    Istanbul, Turkey
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy SQL Connection Problem

    Hello guys. My application works well on my PC. But if I try to use it on the PC which needs my application, it doesn't connect to SQL server. I tried ODBC (MySQL ODBC connector) and SQLite as database server. I don't know what causes to error; I've copied required DLLs, checked my connection code but found nothing.

    Here is my connection function:

    Qt Code:
    1. QSqlDatabase library::database()
    2. {
    3. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    4. db.setDatabaseName("Library");
    5. bool ok = db.open();
    6. if (!ok) { QMessageBox::critical(this, "Error!", "Can't connect to database."); }
    7. return db;
    8. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance for your replies.

  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: SQL Connection Problem

    see if this post helps:
    http://www.qtcentre.org/forum/f-inst...ows-24775.html

    btw: are you setting the user credentials elsewhere?

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

    Utku (25th October 2009)

  4. #3
    Join Date
    Oct 2009
    Location
    Istanbul, Turkey
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SQL Connection Problem

    Quote Originally Posted by schnitzel View Post
    btw: are you setting the user credentials elsewhere?
    I'm setting them in Windows' own programme. It is under Control Panel > Administritive Tools > Data Sources

  5. #4
    Join Date
    Oct 2009
    Location
    Istanbul, Turkey
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SQL Connection Problem

    Thanks a lot schnitzel. I created a directory named "sqldrivers" and copied qsqlodbc.dll to under it. Works well now.

Similar Threads

  1. Replies: 3
    Last Post: 30th March 2009, 19:25
  2. Problem with a UDP connection between two programs
    By fraubrj in forum Qt Programming
    Replies: 8
    Last Post: 10th January 2009, 13:54
  3. QSslSocket problem
    By The Storm in forum Qt Programming
    Replies: 5
    Last Post: 23rd March 2008, 12:58
  4. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 10:22
  5. QTcpsocket - connection problem
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2007, 17:03

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.