Note that there are some explanatory texts on larger screens.

plurals
  1. POConnecting to MS SQL Server 2005 from Mac using Ruby, ODBC and FreeTDS
    text
    copied!<p>I'm having trouble connecting to a SQL Server 2005 install from this very simple Ruby app:</p> <pre><code>#!/usr/bin/env ruby require 'rubygems' require 'sequel' Sequel.odbc('dev04')['select top 1 * from users'].all </code></pre> <p>The <code>dev04</code> DSN points to my <code>odbc.ini</code> file entry:</p> <pre><code>[dev04] Driver = FreeTDS Description = ODBC connection via FreeTDS Trace = 1 Servername = dev04 Database = Dev04 UID = uDev04 PWD = pwdDev04 </code></pre> <p><code>FreeTDS</code> is installed in odbcinst.ini and it points to this configuration in <code>freetds.conf</code>:</p> <pre><code>[dev04] host = hm602.mycompany.com port = 1433 tds version = 7.0 </code></pre> <p>This works:</p> <pre><code>carlos$ tsql -S dev04 -U uDev04 -P pwdDev04 locale is "en_GB.UTF-8" locale charset is "UTF-8" 1&gt; exit carlos$ </code></pre> <p>And so does this:</p> <pre><code>carlos$ iodbctest "DSN=dev04;UID=uDev04;PWD=pwdDev04" iODBC Demonstration program This program shows an interactive SQL processor Driver Manager: 03.52.0406.1211 Driver: 0.82 (libtdsodbc.so) SQL&gt;exit Have a nice day. carlos$ </code></pre> <p>When I run that Ruby script, though, I get this error:</p> <pre><code>carlos$ ruby mssql.rb /Library/Ruby/Gems/1.8/gems/sequel-3.4.0/lib/sequel/adapters/odbc.rb:37:in `initialize': ODBC::Error 01000 (20002) [FreeTDS][SQL Server]Adaptive Server connection failed (Sequel::DatabaseConnectionError) from /Library/Ruby/Gems/1.8/gems/sequel-3.4.0/lib/sequel/adapters/odbc.rb:37:in `connect' from /Library/Ruby/Gems/1.8/gems/sequel-3.4.0/lib/sequel/adapters/odbc.rb:37:in `connect' from /Library/Ruby/Gems/1.8/gems/sequel-3.4.0/lib/sequel/database.rb:92:in `initialize' ... </code></pre> <p>I understand the 'Adaptive Server connection failed' error can occur due to TDS protocol version discrepancies. I've checked the logs and they all seem to be using the correct version (7.0), so I'm at a complete loss as to why this could be happening.</p> <p>Any pointers?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload