Discussion:
[soci-users] "Data source name not found" from C++ SOCI code, but works elsewhere
Alex Zamanian
2013-07-23 01:28:59 UTC
Permalink
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
Alex Zamanian
2013-07-23 16:43:09 UTC
Permalink
OK, I got this working.


I needed to change the Driver line in the .ini file to:
Driver=/opt/freetds-0.91-x86_64/lib/libtdsodbc.so




________________________________
From: Alex Zamanian <***@yahoo.com>
To: "soci-***@lists.sourceforge.net" <soci-***@lists.sourceforge.net>
Sent: Monday, July 22, 2013 9:28 PM
Subject: [soci-users] "Data source name not found" from C++ SOCI code, but works elsewhere



I successfully set up a DSN to a SQLServer database creating the following .ini file:
--
[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
Mateusz Loskot
2013-07-23 22:39:04 UTC
Permalink
Post by Alex Zamanian
OK, I got this working.
Driver=/opt/freetds-0.91-x86_64/lib/libtdsodbc.so
Alex,

I'm glad you've found the solution.
I personally have not tried SOCI with the FreeTDS implementation.
I recall that I had some weird issues with iODBC configuration,
so for testing, I stick to unixODBC and this is the implementation
we test on Travis CI.

Perhaps we should add FreeTDS configuration too.

Feel free to submit issue at GitHub, if you wish.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Alex Zamanian
2013-07-23 16:43:09 UTC
Permalink
OK, I got this working.


I needed to change the Driver line in the .ini file to:
Driver=/opt/freetds-0.91-x86_64/lib/libtdsodbc.so




________________________________
From: Alex Zamanian <***@yahoo.com>
To: "soci-***@lists.sourceforge.net" <soci-***@lists.sourceforge.net>
Sent: Monday, July 22, 2013 9:28 PM
Subject: [soci-users] "Data source name not found" from C++ SOCI code, but works elsewhere



I successfully set up a DSN to a SQLServer database creating the following .ini file:
--
[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
Loading...