title: isql and tsql is connecting to sql server but when connecting with perl ODBC it's getting failed
body: <p>I am trying to run connect to a MSSQL server from a RHEL 5.5 server with FreeTDS and unixODBC.</p>
  
  <p>Using tsql i can connect to the server with</p>
  
  <pre><code>tsql -S mssqltest -U &lt;username&gt; -P &lt;password&gt;
  </code></pre>
  
  <p>It's getting connected successfully</p>
  
  <pre><code>isql -v mssqltest 'username' 'password' -b -q
  </code></pre>
  
  <p>Also connects without any problem</p>
  
  <p>But in perl I get a error message as follows</p>
  
  <pre><code>DBI connect('mssqltest',&lt;username&gt;,...) failed: [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found (SQL-01000) at test.pl line 14
  Can't connect to DBI:ODBC:mssqltest: [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found (SQL-01000) at test.pl line 14.
  </code></pre>
  
  <p>I tried using FreeTDS as ODBC Driver that also gives similar error also I tried using servername instead of server_ip, but the error continues</p>
  
  <pre><code>DBI connect('Driver=FreeTDS;Server=&lt;server_ip&gt;',&lt;username&gt;,...) failed: [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found (SQL-01000) at test.pl line 14
  Can't connect to DBI:ODBC:Driver=FreeTDS;Server=&lt;server_ip&gt;: [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found (SQL-01000) at test.pl line 14.
  </code></pre>
  
  <p>my perl code</p>
  
  <pre><code>#!/usr/bin/perl -w
  use strict;
  
  use DBI;
  
  # Replace datasource_name with the name of your data source.
  # Replace database_username and database_password
  # with the SQL Server database username and password.
  my $data_source = q/DBI:ODBC:mssqltest/;
  my $user = q/&lt;username&gt;/;
  my $password = q/&lt;password&gt;/;
  
  # Connect to the data source and get a handle for that connection.
  my $dbh = DBI-&gt;connect($data_source, $user, $password)
      or die "Can't connect to $data_source: $DBI::errstr";
  
  # This query generates a result set with one record in it.
  my $sql = "SELECT TOP 3 * FROM tablename";
  
  # Prepare the statement.
  my $sth = $dbh-&gt;prepare($sql)
      or die "Can't prepare statement: $DBI::errstr";
  
  # Execute the statement.
  $sth-&gt;execute();
  
  # Print the column name.
  print "$sth-&gt;{NAME}-&gt;[0]\n";
  
  # Fetch and display the result set value.
  while ( my @row = $sth-&gt;fetchrow_array ) {
     print "@row\n";
  }
  
  # Disconnect the database from the database handle.
  $dbh-&gt;disconnect;
  </code></pre>
  
  <p>My config files are:</p>
  
  <p>FreTDS/odbc.ini</p>
  
  <pre><code>;
  ;  odbc.ini
  ;
  [ODBC Data Sources]
  JDBC = Sybase JDBC Server
  
  [JDBC]
  Driver          = /usr/local/lib/libtdsodbc.so
  Description     = Sybase JDBC Server
  Trace           = No
  Servername      = JDBC
  Database        = pubs2
  UID             = guest
  
  [Default]
  Driver          = /usr/local/lib/libtdsodbc.so
  </code></pre>
  
  <p>odbc.ini</p>
  
  <pre><code>[ODBC Data Sources]
  TS = FreeTDS
  
  [TS]
  Driver = FreeTDS
  Description = ODBC to SQLServer via FreeTDS
  Trace = No
  Servername = sql-server
  Database = RKDB
  
  [mssqltest]
  Description     = MS SQL connection to mssqltest database
  Driver          = FreeTDS
  Database        = RKDB
  Server          = &lt;server_ip&gt;
  UserName        = &lt;username&gt;
  Password        = &lt;password&gt;
  Trace           = Yes
  Port            = 1754
  </code></pre>
  
  <p>obcinst.ini</p>
  
  <pre><code>[FreeTDS]
  Description=TDS driver (Sybase/MS SQL)
  Driver=/usr/local/lib/libtdsodbc.so
  UsageCount=2
  </code></pre>
  
  <p>freetds-dev.0.99.761/freetds.conf</p>
  
  <pre><code>#   $Id: freetds.conf,v 1.12 2007-12-25 06:02:36 jklowden Exp $
  #
  # This file is installed by FreeTDS if no file by the same
  # name is found in the installation directory.
  #
  # For information about the layout of this file and its settings,
  # see the freetds.conf manpage "man freetds.conf".
  
  # Global settings are overridden by those in a database
  # server specific section
  [global]
          # TDS protocol version
          tds version = auto
  
          # Whether to write a TDSDUMP file for diagnostic purposes
          # (setting this to /tmp is insecure on a multi-user system)
  ;       dump file = /tmp/freetds.log
  ;       debug flags = 0xffff
  
          # Command and connection timeouts
  ;       timeout = 10
  ;       connect timeout = 10
  
          # If you get out-of-memory errors, it may mean that your client
          # is trying to allocate a huge buffer for a TEXT field.
          # Try setting 'text size' to a more reasonable limit
          text size = 64512
  
  # A typical Sybase server
  [egServer50]
          host = symachine.domain.com
          port = 5000
          tds version = 5.0
  
  # A typical Microsoft server
  [egServer70]
          host = ntmachine.domain.com
          port = 1433
          tds version = 7.0
  
  [mssqltest]
          host = &lt;server_ip&gt;
          port = 1754
          tds version = 8.0
  </code></pre>
  
  <p>/usr/local/etc/freetds.conf</p>
  
  <pre><code>#   $Id: freetds.conf,v 1.12 2007-12-25 06:02:36 jklowden Exp $
  #
  # This file is installed by FreeTDS if no file by the same
  # name is found in the installation directory.
  #
  # For information about the layout of this file and its settings,
  # see the freetds.conf manpage "man freetds.conf".
  
  # Global settings are overridden by those in a database
  # server specific section
  [global]
          # TDS protocol version
          tds version = auto
  
          # Whether to write a TDSDUMP file for diagnostic purposes
          # (setting this to /tmp is insecure on a multi-user system)
  ;       dump file = /tmp/freetds.log
  ;       debug flags = 0xffff
  
          # Command and connection timeouts
  ;       timeout = 10
  ;       connect timeout = 10
  
          # If you get out-of-memory errors, it may mean that your client
          # is trying to allocate a huge buffer for a TEXT field.
          # Try setting 'text size' to a more reasonable limit
          text size = 64512
  
  # A typical Sybase server
  [egServer50]
          host = symachine.domain.com
          port = 5000
          tds version = 5.0
  
  # A typical Microsoft server
  [sql-server]
          host = TH-SSRS-DB
     InstanceName = RKSSRSDB
          #port = 1754
          tds version = 8.0
  
  client charset = UTF-8
  
  [mssqltest]
          host = &lt;server_ip&gt;
          port = 1754
          tds version = 8.0
  </code></pre>
  
  <p>Please help.</p>