Results 1 to 3 of 3

Thread: ODBC to mssql2008express

  1. #1
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default ODBC to mssql2008express

    Hello friends,

    I have problem to connect to 2008 express Database.

    Qt Code:
    1. static bool createConnection(QString driver= "QODBC",
    2. QString connectionstr="DRIVER={SQL Server};"
    3. "Server=IP\\Instance;Trusted_Connection=no;"
    4. "Database=Databasename;Uid="";Pwd="";"
    5. )
    6. {
    7. QSqlDatabase db = QSqlDatabase::addDatabase(driver);
    8. db.setDatabaseName(connectionstr);
    9. db.setUserName("");
    10. db.setPassword("");
    11. if (!db.open()) {
    12. QSqlError err = db.lastError ();
    13. QMessageBox::information(0, QObject::tr("Cannot open database"), err.text());
    14. return false;
    15. }
    16. return true;
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

    with this code I have no problem to Connect to mssql 2005 but with 2008 it doesn´t connect.

    Have anybody an idea????

  2. #2
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC to mssql2008express

    Did you try to connect to 2008 sql with these credentials from some "native" M$soft products/drivers?

    Are you using 4.5 with (should be now) LGPL db drivers? I did not check it out myself and very curious to find out.

  3. #3
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC to mssql2008express

    I connect it from my program.

    I solve it. It must be

    Qt Code:
    1. static bool createConnection(QString driver= "QODBC",
    2. QString connectionstr="DRIVER={SQL Server Native Client 10.0};"
    3. "Server=IP\\Instance;Trusted_Connection=yes;"
    4. "Database=Databasename;Uid="";Pwd="";"
    5. )
    6. {
    7. QSqlDatabase db = QSqlDatabase::addDatabase(driver);
    8. db.setDatabaseName(connectionstr);
    9. if (!db.open()) {
    10. QSqlError err = db.lastError ();
    11. QMessageBox::information(0, QObject::tr("Cannot open database"), err.text());
    12. return false;
    13. }
    14. return true;
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    And you have to install the native sql client.
    Yes I use Qt4.5.0 ans compile it with the ODBC flag etc..

    thanx

Similar Threads

  1. ODBC function sequence error
    By joseph in forum Qt Programming
    Replies: 9
    Last Post: 7th November 2014, 12:32
  2. Frustrated with ODBC
    By darkadept in forum Qt Programming
    Replies: 3
    Last Post: 8th December 2011, 03:31
  3. ODBC Database plugin is not loading
    By QPlace in forum Qt Programming
    Replies: 11
    Last Post: 4th November 2008, 15:04
  4. ODBC Oracle. Unable to connect to database
    By egil in forum Qt Programming
    Replies: 2
    Last Post: 17th October 2008, 13:46
  5. remote ODBC data source
    By mchara in forum Qt Programming
    Replies: 7
    Last Post: 10th December 2007, 10:39

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.