Results 1 to 2 of 2

Thread: QSqlDatabase sql server

  1. #1
    Join Date
    Jan 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation QSqlDatabase sql server

    I have started in QT and sql server : I have read a lot of examples to do my connection but no one works
    here ir my code :


    Qt Code:
    1. /*db = QSqlDatabase::addDatabase("QODBC");
    2.   db.setDatabaseName("DRIVER={SQL Server};Trusted_Connection=Yes");
    3.   db.setDatabaseName("BD_83_MATRICULA");
    4.   db.setHostName("localhost");
    5.   db.setUserName("Bytes");*/
    6. db = QSqlDatabase::addDatabase("QODBC");
    7.  
    8. QString dns = "DRIVER={SQL Native Client};SERVER=localhost;DATABASE=BD_83_MATRICULA;UID=BYTES;Trusted_Connection=Yes;";
    9. db.setDatabaseName(dns);
    10.  
    11. if(!db.open())
    12. {
    13. qDebug() << db.lastError().text();
    14. QMessageBox::critical(0, qApp->tr("mensaje"),
    15. qApp->tr("No conecto\n"
    16. "Presione cancelar."),QMessageBox::Cancel);
    17. }
    18. else
    19. {
    20. QMessageBox::information(0, "Mensaje","Conecto");
    21. }
    To copy to clipboard, switch view to plain text mode 

    and the error says:

    "[Microsoft][Administrador de controladores ODBC] No se encuentra el nombre del origen de datos y no se especificó ningún controlador predeterminado QODBC3: Unable to connect"

    i need the help please

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlDatabase sql server

    Google Translation
    Qt Code:
    1. [Microsoft] [ODBC Driver Manager] Can not find the data source name and no default driver specified
    2. QODBC3: Unable to connect
    To copy to clipboard, switch view to plain text mode 
    I would start by either leaving the trusted connection option out (using SQL Server authentication), or leaving the uid and pwd options without values (forcing a trusted connection)
    http://support.microsoft.com/kb/194641

Similar Threads

  1. Replies: 2
    Last Post: 20th October 2012, 10:06
  2. Replies: 4
    Last Post: 5th December 2011, 17:54
  3. Replies: 0
    Last Post: 2nd December 2011, 19:52
  4. Replies: 1
    Last Post: 11th November 2011, 22:24
  5. [TCP Server] Server only sending when terminating
    By papperlapapp in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2010, 19:41

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.