Results 1 to 5 of 5

Thread: Connection with MS SQL

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    9
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connection with MS SQL

    You will connect to SQL Server using FreeTDS plugin with something like this:

    Qt Code:
    1. // Note: QT4
    2. QSqlDatabase db = QSqlDatabase::addDatabase("QTDS7");
    3. db.setDatabaseName(database);
    4. db.setHostName(host);
    5. db.setUserName(user);
    6. db.setPassword(pass);
    7.  
    8. setenv("TDSVER", "8.0", 1);
    9. setenv("TDSPORT", dbport, 1); //! setPort() does not work properly
    10.  
    11. if (!db.open())
    12. {
    13. qWarning("Erro opening database connection: " + db.lastError().text());
    14. return 1;
    15. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Zatraz; 4th September 2006 at 17:48.

  2. #2
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Connection with MS SQL

    Quote Originally Posted by Zatraz
    You will connect to SQL Server using FreeTDS plugin with something like this:

    Qt Code:
    1. // Note: QT4
    2. QSqlDatabase db = QSqlDatabase::addDatabase("QTDS7");
    3. db.setDatabaseName(database);
    4. db.setHostName(host);
    5. db.setUserName(user);
    6. db.setPassword(pass);
    7.  
    8. setenv("TDSVER", "8.0", 1);
    9. setenv("TDSPORT", dbport, 1); //! setPort() does not work properly
    10.  
    11. if (!db.open())
    12. {
    13. qWarning("Erro opening database connection: " + db.lastError().text());
    14. return 1;
    15. }
    To copy to clipboard, switch view to plain text mode 
    If I am using the above code then it throws an error :

    QSqlDatabase: QTDS7 driver not loaded
    QSqlDatabase: available drivers: QODBC3

    Can you tell me from where I will get QTDS7 driver?

    thanks

Similar Threads

  1. connection problem
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 7th July 2006, 22:14
  2. Replies: 3
    Last Post: 22nd June 2006, 16:27
  3. How do I keep the client connection open ?
    By probine in forum Newbie
    Replies: 2
    Last Post: 25th March 2006, 19:06
  4. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 18:06
  5. Can I launch a dial-up connection in Windows?
    By gtthang in forum Qt Programming
    Replies: 3
    Last Post: 9th February 2006, 12:32

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.