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. Unable to connect remote MSSQL database
Forum Updated to NodeBB v4.3 + New Features

Unable to connect remote MSSQL database

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.7k Views 2 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.
  • I Offline
    I Offline
    iskenderoguz
    wrote on last edited by iskenderoguz
    #1

    I have a MSSQL database on remote. I can reach database via using DBeaver. I wrote code to connect database with Qt 4.8.6. My code is:

    QSqlDatabase db=QSqlDatabase::addDatabase("QODBC");
    db.setHostName("host_name");
    db.setPort(1433);
    db.setDatabaseName("database_name");
    db.setUserName("user");
    db.setPassword("pass");

    db.open(); returns false and
    qDebug()<<db.lastError().text(); returns

    [unixODBC][Driver Manager]Data source name not found, and no default driver specified QODBC3: Unable to connect"

    How can I connect MSSQL database ?

    1 Reply Last reply
    0
    • simowS Offline
      simowS Offline
      simow
      wrote on last edited by
      #2

      Hi, I had to create a DSN in the Windows ODBC settings in the computer management settings.

      Let's Try To Negotiate!

      I 1 Reply Last reply
      0
      • simowS simow

        Hi, I had to create a DSN in the Windows ODBC settings in the computer management settings.

        I Offline
        I Offline
        iskenderoguz
        wrote on last edited by iskenderoguz
        #3

        @simow I do not know how do I create DSN. Can you provide an example ?
        I use Linux.

        Also my odbc.ini file is empty. Is this normal?

        simowS 1 Reply Last reply
        0
        • I iskenderoguz

          @simow I do not know how do I create DSN. Can you provide an example ?
          I use Linux.

          Also my odbc.ini file is empty. Is this normal?

          simowS Offline
          simowS Offline
          simow
          wrote on last edited by
          #4

          @iskenderoguz Oh, you are trying to access a remote MSSQL database via unixODBC? You need to configure the DNS in the /etc/odbc.ini. There are lots of examples on the web.
          The thing is that you need to define a driver library that does the low level communication with the database. The website http://www.unixodbc.org/drivers.html is referencing easysoft: http://www.easysoft.com/products/data_access/odbc-sql-server-driver/index.html providing commercial drivers.

          Let's Try To Negotiate!

          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