Results 1 to 3 of 3

Thread: Error on QODBC

  1. #1
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Error on QODBC

    Hi Everyone

    I Get Error in ODBC when i open connect To DataBase
    Error:
    Qt Code:
    1. [Microsoft][ODBC Driver Manager] Data Source Name Not Found and No Default Driver
    2. specified QODBC3: Unable To Connect
    To copy to clipboard, switch view to plain text mode 

    and I Used This Code:
    Qt Code:
    1. QString servername="LOCALHOST\\SQLEXPRESS";
    2. QString dbname="Test";
    3. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    4. db.setConnectOptions();
    5. QString dsn=QString("Driver=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;").arg(servername).arg(dbname);
    6. db.setDatabaseName(dsn);
    7. if(db.open())
    8. {
    9. QMessageBox::about(this,"","OK");
    10. }
    11. QMessageBox::about(this,"",db.lastError().text());
    To copy to clipboard, switch view to plain text mode 

    Thanks

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error on QODBC

    Have you installed your server with a named instance, instance being SQLEXPRESS? if not try..
    Qt Code:
    1. QString serverName = "localhost";
    2. QString dbName = "Test";
    3.  
    4. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    5. QString dsn = QString("DRIVER={SQL Native Client};SERVER=%1;DATABASE=%2;UID=sa;PWD=;").arg(serverName).arg(dbName);
    6.  
    7. db.setDatabaseName(dsn);
    8.  
    9. db.open();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Error on QODBC

    I Change Instance
    And I Trying Change Code
    But This Error Love Me

Similar Threads

  1. SSL with QODBC ??!
    By codeman in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2010, 09:01
  2. QODBC driver not loaded error
    By Askar in forum Qt Programming
    Replies: 0
    Last Post: 23rd October 2009, 10:35
  3. QODBC addBindValue error
    By jonman364 in forum Qt Programming
    Replies: 0
    Last Post: 2nd July 2008, 20:21
  4. QODBC Driver
    By mchara in forum Qt Programming
    Replies: 2
    Last Post: 17th January 2008, 14:40
  5. qodbc driver not loaded error in release mode
    By mandal in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2006, 09:42

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.