SQL Server for Qt
Solved
General and Desktop
-
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!
-
-
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