PDA

View Full Version : Microsoft SQL Server Connectivity from Mac



deejross
26th January 2011, 19:16
I have been reading up on SQL support in Qt. I know that the QTDS driver is considered obsolete now and that the recommended approach is to use QODBC. This is alright if your application only targets Windows, but what are you supposed to do if you want your application to support Mac and Linux? I know there is unixODBC, but that is not very ideal. The last thing I would want to do is have my users install darwinports, unixODBC, then have to walk them through configuring it for their machines. I am also aware of a couple of paid third-party ODBC drivers for the Mac, but those are proprietary and you have to pay for them.

TDS is still supported on Microsoft SQL servers, even with 2008, so why is the QTDS driver being removed? What other cross-platform options are there to connect to a Microsoft SQL server from Qt? Thanks.

jpujolf
21st October 2011, 09:19
I know it's too late to answer, but I've been fighting with that exact configuration last week and I can tell you what you have to do. You MUST use ODBC to access SQL Server ( from UNIX/LINUX, MAC or Window$ )

- In MAC, install macports and through this, freedts & iodbc ( perhaps you can use the one from OpenLink, but I've uninstalled it... )

You can configure odbinst.ini like this :

[SQL Server]
Description = FreeTDS Driver
Driver = <path_to_lib>/libtdsodbc.so
Setup = <path_to_lib>/libtdsodbc.so

and you can configure freetds.conf like this :

[global]
...

[SQLServer]
tds version = 8.0
client charset = UTF-8

For the connectionString, you must use one like this:

"DRIVER=FreeTDS;SERVER=<ip_or_server_name>;UID=<your_uid>;PWD=<...>;SERVERNAME=SQLServer

Don't forget to set in ODBC's connection options "SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3"

Currently I've found that you must add this when you connect to SQL Server from MAC.
Perhaps last version of FreeTDS 0.82 needs this or perhaps it's my Qt's ODBC driver, I don't know...

..and all must work !!