Results 1 to 2 of 2

Thread: Accessing Microsoft SQL server 2005

  1. #1

    Default Accessing Microsoft SQL server 2005

    HI All,

    I am trying to connect Qt application with MS sql server 2005 with below code

    Qt Code:
    1. QSqlDatabase database = QSqlDatabase::addDatabase("QODBC3");
    2. database.setDatabaseName("DRIVER={SQL Server};SERVER=ITDPC\SQLEXPRESS;DATABASE=MTA;UID=sa;PWD=1;");
    3.  
    4. if(!database.open())
    5. {
    6. qDebug() << database.lastError().text();
    7. QMessageBox::information(0,"","DataBase Init Failed\n");
    8. return 1;
    9. }
    10. else
    11. {
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

    But i am getting error

    "[Microsoft][ODBC SQL Server Driver][DBNETLIB]Specified SQL server not found. [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). QODBC3: Unable to connect"

    My Data source name is Addu. refer attached screen shot images

    Please help to connect Qt application with MS Sql server.

    Thanks

    Yuvaraj
    Attached Images Attached Images

  2. #2
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Accessing Microsoft SQL server 2005

    Perhaps changing \ to \\ or / in DatabaseName ?

    Qt Code:
    1. QSqlDatabase database = QSqlDatabase::addDatabase("QODBC3");
    2. database.setDatabaseName("DRIVER={SQL Server};SERVER=ITDPC\\SQLEXPRESS;DATABASE=MTA;UID=sa;PWD=1;");
    To copy to clipboard, switch view to plain text mode 

    In C++ \ is an escape character...

Similar Threads

  1. 3rd party native Microsoft SQL Server drivers
    By scarleton in forum Newbie
    Replies: 0
    Last Post: 21st September 2010, 00:58
  2. Replies: 2
    Last Post: 2nd June 2010, 12:19
  3. Trying to Connect To SQL Server 2005
    By rossd in forum Installation and Deployment
    Replies: 0
    Last Post: 6th March 2009, 20:56
  4. Poor performance with Qt 4.3 and Microsoft SQL Server
    By Korgen in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2007, 11:28

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.