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. Connect to MSSQL Server without setting up ODBC Data Source
Forum Updated to NodeBB v4.3 + New Features

Connect to MSSQL Server without setting up ODBC Data Source

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 15.3k 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.
  • T Offline
    T Offline
    tbitsky
    wrote on last edited by
    #1

    I'm working on a database project that will ultimately interface with an MS SQL Server 2008 R2 server over a large network. For development, I have MS SQL 2008 R2 Express running on a server in my lab with the IP Address 192.168.16.103.

    If I create an ODBC Data Entry in control panel, I can connect to the remote database without problem. Example:
    @
    db->setDatabaseName( "Server=JOSHUA\SQLEXPRESS;Database=myDataBase;Trusted_Connection=True;" );
    db->setUserName( "tbj" );
    db->setPassword( "..." );
    db->setHostName( "" );
    @
    However, if I try to just connect directly to the database using an IP Address:
    @
    db->setDatabaseName(
    "Data Source=192.168.16.103,1433;Network Library=DBMSSOCN;"
    );

    db->setDatabaseName( "sqlexpress" );
    db->setUserName( "tbj" );
    db->setPassword( "..." );
    db->setHostName( "" );

    @
    Then, I get the error message:
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect.

    It would seen that, no matter what I do, the QODBC driver attempts to connect via a registered data source. Is there any way to avoid this? I was hoping to connect to the database directly, as I would a PostgreSQL database.

    Any advice is greatly appreciated.

    Thanks!
    Tom

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tbitsky
      wrote on last edited by
      #2

      After much research and reading, the answer to this question appears to be an emphatic no. This is disappointing, considering how easily the Microsoft native client makes connecting to a remote data source. The functionality is there; Qt simply isn't bothering to add this feature.

      The solution I'm going to use for my software is to put a button in the settings dialog that opens the ODBC data connection dialog. On a 64-bit system, one would open:

      c:\windows\sysWOW64\odbcad32.exe

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Beowolve
        wrote on last edited by
        #3

        I know its an older post, but the reply is just wrong, if someone else wants to connect, here is the connection string to use:

        @db->setDatabaseName("Driver={SQL Server Native Client 11.0};Server=<ip/host>;Database=<database>;Uid=<userid>;Pwd=<password>;")@

        More info on dsn less connections can be found here:
        "Connection Strings":http://www.connectionstrings.com/

        1 Reply Last reply
        0

        • Login

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