Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using a DSN to connect my QT application to MSSQL Server 2005
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.4k Views 1 Watching
  • 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 Offline
    P Offline
    Prosit
    wrote on 1 Mar 2012, 00:52 last edited by
    #1

    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
    0

    1/1

    1 Mar 2012, 00:52

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved