title: How to connect from ruby to MS Sql Server
body: <p>I'm trying to connect to the sql server 2005 database from *NIX machine:</p>
  
  <p>I have the following configuration: Linux 64bit</p>
  
  <blockquote>
    <p>ruby -v
    ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
    important gems:
    dbd-odbc (0.2.4)
    dbi (0.4.1)
    active record sql server adapter - as plugin</p>
  </blockquote>
  
  <p>ruby-odbc 0.9996 (installed without any options.)
  unixODBC is installed
  freeTDS is installed</p>
  
  <blockquote>
    <p>cat /etc/odbcinst.ini</p>
  </blockquote>
  
  <pre><code>  [FreeTDS]
       Description     = TDS driver (Sybase/MS SQL)
       Driver          = /usr/lib/libtdsodbc.so
       Setup           = /usr/lib/odbc/libtdsS.so
       CPTimeout       =
       CPReuse         =
       FileUsage       = 1
  </code></pre>
  
  <p>DSN:</p>
  
  <pre><code>DRIVER=FreeTDS;TDS_Version=8.0;SERVER=XXXX;DATABASE=XXX;Port=1433;uid=XXX;pwd=XXXX;"
  </code></pre>
  
  <p>or</p>
  
  <pre><code>DRIVER=/usr/lib/libtdsodbc.so;TDS_Version=8.0;SERVER=XXXX;DATABASE=XXX;Port=1433;uid=XXX;pwd=XXXX;"
  </code></pre>
  
  <p>I receive the following error:</p>
  
  <pre><code>&gt;&gt;ActiveRecord::Base.sqlserver_connection({"mode"=&gt;"ODBC", "adapter"=&gt;"sqlserver", "dsn"=&gt;my_dns)
  DBI::DatabaseError: IM002 (0) [unixODBC][Driver Manager]Data source name not found, and no default driver specified
      from /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'
      from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
      from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
      from /opt/ublip/rails/current/vendor/plugins/activerecord-sqlserver-adapter/lib/active_record/connection_adapters/sqlserver_adapter.rb:47:in `sqlserver_connection'
  </code></pre>
  
  <p>It looks like ODBC unable to find appropriate ODBC driver, but I have no ideas why.</p>
  
  <p>I had a problem with /usr/lib/libtdsodbc.so which is empty in default debian package free-tds dev, but i solved it with remove broken package and installation from sources.</p>
  
  <p>Will appreciate any thought!</p>
  
  <p>Note:
  I'm albe to connect using the same steps on mac 10.5</p>