[unixODBC-dev] Connection to MS-SQL

Alejandro Rotolo arotolo at girmet.ru
Sun Jul 18 18:42:02 BST 2004


Sorry ... It wasn't clear enough....
What I meant is that previously, the same piece of code worked with a DNS
pointing to a MySQL server ("pp3") ... and I wanted to use this same code to
conect to a MS-SQL server through a second DNS: "pp4"

In both cases the DNS' (pp3 AND pp4) were tested with isql and worked
fine... the code worked ok with "pp3" ... but when tried to connect to "pp4"
it gives me this odd message...... (error coming from the MySQL driver....)

Here is a piece of my ODBC.INI
[pp3]
Description  = MySQL
Driver  = MySQL
Server  = localhost
Database  = PL02

[pp4]
Description  = FreeTDS
Driver  = FreeTDS
Servername  = MyServer70 // (Actually referring to freetds.conf)
Database  = PL02

Here is my odbcconfig.ini
[MySQL]
Driver  = /usr/lib/libmyodbc3.so
Setup  = /usr/local/lib/libodbcmyS.so

[FreeTDS]
Driver  = /usr/local/lib/libtdsodbc.so
Setup  = /usr/local/lib/libtdsS.so

My question basically is if there is something else referring to the driver
than the connection string or if I'm overlooking something in the handles
allocation...
But in any case I'm most probably doing a very VERY silly mistake
somewhere... I have the hope that somebody see it straight and put me out of
my missery :-)

In any case thanks and regards
Alejandro


----- Original Message ----- 
From: "Martin J. Evans" <martin at easysoft.com>
To: <unixodbc-dev at mail.easysoft.com>
Sent: Saturday, July 17, 2004 5:09 PM
Subject: Re: [unixODBC-dev] Connection to MS-SQL


> 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.
>
> [FreeTDS]
> Driver = /path_to_freetds_driver/driver.so
>
> [MySQL]
> 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.
>
> [pp4]
> 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
> --
> 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 = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&_Env);
> > 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
> >
>
> _______________________________________________
> unixODBC-dev mailing list
> unixODBC-dev at mail.easysoft.com
> http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
>




More information about the unixODBC-dev mailing list