Problems with Ruby ODBC connection to MSSQL 2008

This might not be the right place for this question, but I'm hoping somebody here might be able to point me in the right (or even possibly right) direction. I recently tried querying an MSSQL 2008 database from Ruby. It works fine unless I use a parameterized query. As an example:

d = DBI.connect('DBI:ODBC:odbcdsn', 'name', 'pw')
d.select_all "SELECT * FROM atable WHERE afield = 'info';"
=> [[7, 'info', 123]]

d.select_all "SELECT * FROM atable WHERE afield = ?;", 'info'
=> DBI::DatabaseError: INTERN (0) [RubyODBC]No data found
        from /usr/local/lib/ruby/site_ruby/1.8/dbd/odbc/database.rb:86:in `execute'
        from /usr/local/lib/ruby/gems/1.8/gems/dbi-0.4.3/lib/dbi/handles/database.rb:81:in `execute'
        from /usr/local/lib/ruby/gems/1.8/gems/dbi-0.4.3/lib/dbi/handles/database.rb:128:in `select_all'
        from (irb):4

Does "INTERN (0)" indicate there's a problem in compiled code somewhere?

This issue is happening on VMs with Debian Etch, Ruby 1.8.6, ruby-odbc 0.99994, Ruby DBI 0.4.3, FreeTDS 0.63, and unixODBC 2.2.11. Parts are outdated, I know, but that's what I'm stuck with for now.

I know it will work correctly on a Debian machine with Ruby 1.8.6, ruby-odbc 0.99994, Ruby DBI 0.4.5, FreeTDS 0.82, and unixODBC 2.2.14.

I've been stuck on this problem for a while so I'm really just hoping somebody has seen something similar or has any kind of suggestions on where to look next. I'm guessing it's an issue with FreeTDS or unixODBC. I have no idea how to figure out which of those (if either) is causing the problem.

I'm also not sure I have a good understanding of how all this works together. Is it correct to say that Ruby DBI uses ruby-odbc which uses unixODBC which uses FreeTDS? And ruby-odbc is basically a Ruby wrapper around unixODBC? If it is an issue in unixODBC, would I need to upgrade unixODBC and then rebuild ruby-odbc?

Any advice would be very appreciated.

This error does originate (not surprisingly, I suppose) from ruby-odbc. I believe that means the problem is with unixODBC or FreeTDS, but I'm still having trouble tracking it down. I'm also having trouble making sure I'm correctly upgrading FreeTDS and unixODBC, but that's a question for a different news group.

···

On Friday, June 10, 2011 11:57:45 AM UTC-5, yermej wrote:

=> DBI::DatabaseError: INTERN (0) [RubyODBC]No data found

Just for reference, it turns out that "tds version" in freetds.conf can be set to 8.0 for MS SQL 2000, but must be set for 7.0 for MS SQL 2008. I only wish I'd thought to try that sooner.