Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

[unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001)

by perlraj (Acolyte)
on Dec 12, 2012 at 08:04 UTC ( #1008467=perlquestion: print w/replies, xml ) Need Help??

perlraj has asked for the wisdom of the Perl Monks concerning the following question:

Hi I have a problem with connecting MSSQL Server using FreeTDS
I am using Ubuntu 12.04 LTS
I have installed unixODBC in the path /usr/local/unixODBC and freeTDS in /usr/local/freeTDS and got all the files like odbc.ini, odbcinst.ini and freetds.conf in the path /etc
i am trying to connect with DNS less connection following the instructions from the link

www.freetds.org/userguide/dsnless.htm

I am getting the error [unixODBC][FreeTDS][SQL Server] Unable to connect to data source (SQL-08001)

Driver config file odbcinst.ini [FreeTDS] Driver=/usr/local/freetds/lib/libtdsodbc.so Setup=/usr/local/freetds/lib/libtdsodbc.so Threading=0 FileUsage=1 DontDLClose=1
Perl Program #!/usr/bin/perl use strict; use DBI; $dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;database=$database;"; $dbh = DBI->connect("$dsn","$user","$password") or die "\n$DBI::errstr +\n";

Replies are listed 'Best First'.
Re: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001)
by karlgoethebier (Monsignor) on Dec 12, 2012 at 10:24 UTC

    FreeTDS comes with some useful tools for debugging. Please take a look at Troubleshooting ODBC connections.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      Hi Thanks a lot

      My odbc.ini

      [SQLServer] Driver=/usr/local/freetds/lib/libtdsodbc.so Description=SQL Server DSN created during installation Server=10.101.11.87 Port=1433 User= Password= Language= Database= Logging=0 LogFile= QuotedId=Yes AnsiNPW=Yes Mars_Connection=No

      But I am getting the error when i execute the command

      $ osql -S servername -U username -P password
      checking shared odbc libraries linked to isql for default directories. +.. trying /usr ... no trying /loc ... no trying /tmp/sql.log ... no trying /home ... no trying /.odbc.ini ... no trying /usr/local/etc ... OK checking odbc.ini files reading /home/perlzuser/.odbc.ini [10.101.11.87] not found in /home/perlzuser/.odbc.ini reading /usr/local/etc/odbc.ini [10.101.11.87] found in /usr/local/etc/odbc.ini found this section: looking for driver for DSN [10.101.11.87] in /usr/local/etc/odbc.ini no driver mentioned for [10.101.11.87] in odbc.ini looking for driver for DSN [default] in /usr/local/etc/odbc.ini osql: error: no driver found for [10.101.11.87] in odbc.ini
        osql: error: no driver found for [10.101.11.87] in odbc.ini

        ...something is wrong with your configuration ;-)

        I don't use FreeTDS, it's new to me - but i've just read the manual a bit and by search i found this:

        /etc $ cat freetds.conf [SERVER] host = 192.168.0.10 port = 1433 tds version = 7.0 /etc$ cat odbcinst.ini [FreeTDS] Description = TDS driver (Sybase/MS SQL) Driver = /usr/lib/odbc/libtdsodbc.so Setup = /usr/lib/odbc/libtdsS.so CPTimeout = CPReuse = FileUsage = 1 /etc$ cat odbc.ini [SERVER] Driver = FreeTDS Description = ODBC connection via FreeTDS Trace = No Servername = SERVER Database = DATABASE

        Differences i can see:

        1. No database in your odbc.ini
        2. In your odbcinst.ini Setup is the same as Driver (don't know if this matters)

        Not very much, but perhaps it helps a bit to get ahead.

        Update: The FreeTSD Archives

        Regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

Re: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001)
by tobyink (Abbot) on Dec 12, 2012 at 17:17 UTC

    For what it's worth, I've had a lot more luck using DBD::Sybase to connect to MSSQL servers than ODBC.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      ...but as far as i remember, don't you need also FreeTDS when connecting to MSSQL with DBD::Sybase?

      Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        Indeed you do.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1008467]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2019-08-18 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (134 votes). Check out past polls.

    Notices?