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. SQL Server for Qt
Forum Updated to NodeBB v4.3 + New Features

SQL Server for Qt

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 454 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.
  • D Offline
    D Offline
    Daniziz
    wrote on last edited by
    #1

    Hi all,

    I've read some posts about how to install ODBC drivers for Qt because i need to connect my app to a SQL Server.

    Here is what I've done:

    • I've downloaded unixODBC drivers: http://www.unixodbc.org/

    • I've done ./configure process and install process.

    • I've run qmake with acording to docs:

    sudo /opt/Qt/5.11.2/gcc_64/bin/qmake -makefile "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lodbc -ldl" odbc.pro
    
    • I've run make and make install with no problems.

    But whern I run my app, I get this message from my

    mDatabase.lastError().text();
    

    "[unixODBC][Driver Manager]Can't open lib 'SQL SERVER' : file not found QODBC3: Unable to connect"

    I connect database with this code:

    dbsqlserver::dbsqlserver(const QString &Server, const QString &Driver, const QString &User, const QString &Passwd, const QString &Databasename, bool TrustedConnection)
    {
        mDatabase = QSqlDatabase::addDatabase("QODBC");
        mDatabasename = Databasename;
        mServer = Server;
        mDriver = Driver;
        mUser = User;
        mPasswd = Passwd;
        mTrustedConnection = TrustedConnection;
    }
    

    regards!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Daniziz
      wrote on last edited by
      #2

      Hi all,

      I was setting Driver name in wrong way.

      I've changed "SQL SERVER" to "ODBC Driver 17 for SQL Server"

      mDatabase.setDatabaseName("DRIVER={ODBC Driver 17 for SQL Server};"
                                    "Server=XXXX;"
                                    "Database=XXXXX;"
                                    "Uid=XXX;"
                                    "Port=1433;"
                                    "Pwd=XXXX;"
                                    "WSID=.");
      

      Works like a charm.

      Thanks all

      1 Reply Last reply
      3

      • Login

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