[unixODBC-dev] Connection to MS-SQL

Martin J. Evans martin at easysoft.com
Sat Jul 17 14:09:14 BST 2004

I'm confused what you are asking. You seem to suggest you've had MySQL working
and wanting to add access to MS SQL Server but the error is one connecting to
MySQL so I presume you mean that DSN pp4 should be a freetds one.

Firstly, run odbcinst -j to check where the odbcinst.ini and system/user ini
files are located. Edit odbcinst.ini and look for a [xxx] entries. You need two
entries, one for FreeTDS driver and one for MySQL - each should have a Driver =
path where path points to the MySQL and FreeTDS drivers. e.g.

Driver = /path_to_freetds_driver/driver.so

Driver = /path_to_mysql_driver/driver.so

Then in your odbc.ini files (system or user) you create DSNs which reference
the driver entries in odbcinst.ini. e.g.

Driver = FreeTDS (Here FreeTDS is a reference to the entry in odbcinst.ini)
attribute = value

I suspect your DSN which you intend to be using FreeTDS says Driver = xxx
where xxx is for MySQL driver or you have copied your MySQL entry in
odbcinst.ini and just renamed it FreeTDS but left it pointing to the MySQL
driver (However this would not explain isql working to pp4.

So, carefully check your odbcinst.ini and odbc.ini files.

Martin J. Evans
Development, Easysoft Ltd

Quoting Alejandro Rotolo <arotolo at girmet.ru>:

> Hi All,
> I've been playing for some time with UnixODBC against a MySQL database in a
> Linux Mandrake Box. 
> Now I wanted to use the same piece of code but against a MS SQL in the
> network.
> Downloaded FreeTds (0.62), Installed, set up a DSN and tryed with tsql (from
> freetds) and isql (from unixODBC) and in both cases with good results.... Now
> when I go to my piece of code :
> Err = SQLSetEnvAttr(_Env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
> Err = SQLAllocHandle(SQL_HANDLE_DBC, _Env, &_hdbc);
> // some error treatment.....
> // Connect to the datasource
> Err = SQLConnect(_hdbc, (SQLCHAR *) "pp4", SQL_NTS, (SQLCHAR *) "user",
> SQL_NTS, (SQLCHAR *) "pass", SQL_NTS);
> // some error treatment.....
> I receive the following error message from the SQLConnect:
> Error: 1044
> Msg: [unixODBC][MySQL][ODBC 3.51 Driver]Access denied for user: '@localhost'
> to database 'Pl02'
> The odd part is that the message comes from the MySQL driver apparently.... I
> couldn't find any other reference to the driver than in the ODBC.ini DNS....
> and there it says FREETDS......
> Somebody can hint me what I'm doing wrong ? .... I'm sure that should be
> something VERY silly from my side ... but I've been hanging around quite a
> long time already and I simply can't see it.
> Many Thanks and regards
> Alejandro

More information about the unixODBC-dev mailing list