Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Using a DSN to connect my QT application to MSSQL Server 2005

    General and Desktop
    1
    1
    2306
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Prosit last edited by

      So here is my little code snibbit that i use to connect to my database:
      @
      QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
      db.setHostName("194.47.150.169");
      db.setDatabaseName("mytest");
      //db.setDatabaseName("DRIVER={SQL Server};SERVER=194.47.150.169;DATABASE=MYDB;UID=UID;PWD=PWD");

      if(db.open())
      {
          this->setWindowTitle("Database connected well");
          db.close();
      }
      else
      {
          QMessageBox::critical(0, QObject::tr("Database Error"), db.lastError().text());
      }
      

      @

      The error i get in my messagebox is:
      [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user". The user is not associated with a trusted SQL Server connection. QODBC3: Unable to connect.

      I am using a remote server to connect to and using the MSSQL management studio i can connect to that address using the real ID and PW and when i added the DNS with odbcad32.exe and tested the connection there was no problem.
      The part i commented away works if i use that way to connect. The name of the DNS and what is written in my code is the same.

      It seems to me that its something wrong with my DNS but i cant figure out what. Hope you can help me.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post