Unable to connect remote MSSQL database
-
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 ?
-
Hi, I had to create a DSN in the Windows ODBC settings in the computer management settings.
-
@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?
-
@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.