Alex Zamanian
2013-07-23 01:28:59 UTC
I successfully set up a DSN to a SQLServer database creating the following .inifile:
--
[test9]
Driver=FreeTDS
Description=Please work
Server=XXXX
Port=1433
Database=XXXX
--
and running "/opt/unixODBC-2.3.1-x86_64/bin/odbcinst -i -s -f" on it.
The reason I say it was successful, was because after some fiddling (setting the environment variable TDSVER to 8.0 and setting my PATH to include /opt/unixODBC-2.3.1-x86_64/bin:/opt/freetds-0.91-x86_64/bin), I was able to connect to the database using isql:
/opt/unixODBC-2.3.1-x86_64/bin/isql -v test9 usr pass
But in my C++ code:
session sql(soci::odbc, "DSN=test9;UID=usr;PWD=pass");
throws an odc_soci_error exception:
ODBC Error Code: IM002
Native Error Code: 0
SOCI Message: Error Connecting to database
ODBC Message: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
The environment when running the C++ application appears to be same as when I run isql (same PATH, TDSVER, and running "odbcinst -q -s" from within the program lists test9 as a valid DSN).
I'm new to all this, any help in what's going on or how to debug this further is much appreciated.
Thanks,
Frank
--
[test9]
Driver=FreeTDS
Description=Please work
Server=XXXX
Port=1433
Database=XXXX
--
and running "/opt/unixODBC-2.3.1-x86_64/bin/odbcinst -i -s -f" on it.
The reason I say it was successful, was because after some fiddling (setting the environment variable TDSVER to 8.0 and setting my PATH to include /opt/unixODBC-2.3.1-x86_64/bin:/opt/freetds-0.91-x86_64/bin), I was able to connect to the database using isql:
/opt/unixODBC-2.3.1-x86_64/bin/isql -v test9 usr pass
But in my C++ code:
session sql(soci::odbc, "DSN=test9;UID=usr;PWD=pass");
throws an odc_soci_error exception:
ODBC Error Code: IM002
Native Error Code: 0
SOCI Message: Error Connecting to database
ODBC Message: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
The environment when running the C++ application appears to be same as when I run isql (same PATH, TDSVER, and running "odbcinst -q -s" from within the program lists test9 as a valid DSN).
I'm new to all this, any help in what's going on or how to debug this further is much appreciated.
Thanks,
Frank