# IronRuby and ODBC

**URL:** <https://www.ruby-forum.com/t/ironruby-and-odbc/188743>\
**Category:** IronRuby\
**Created:** [May 17, 2010, 5:51pm UTC](https://www.ruby-forum.com/t/ironruby-and-odbc/188743 "2010-05-17T17:51:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Sjoberg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@Tim\_Sjoberg](https://www.ruby-forum.com/u/Tim_Sjoberg)\
**Post date:** [May 17, 2010, 5:51pm UTC](https://www.ruby-forum.com/t/ironruby-and-odbc/188743/1 "2010-05-17T17:51:38Z")

</div>

Hi

I’m currently running IronRuby (on Rails, in IIS7) on Windows Server  
2008  
connecting to SQLServer 2008. As per the guide I am using the  
activerecord-sqlserver-adapter in ADONET mode. It is working fine except  
that it is slower than cancer itself.

I have the same website running on my Laptop (running Ubuntu Linux)  
connecting over LAN to the sqlserver database. For exactly the same page  
the  
DB time on the page request never goes below 1200ms in ironruby (the db  
is  
local to this machine), while in linux making an odbc connection, to a  
database database from a different machine, the same page gets as low as  
60ms for the DB time. Now I don’t believe that the fault lies with  
IronRuby  
itself, but rather with the db connector.

What I would like to know is how exactly to go about making an odbc  
connection to the database. Currently you need to use ruby-odbc, at  
least  
activerecord-sqlserver-adapter tries to do it, but its not pure ruby and  
requires compilation. There are precompiled versions but I have no idea  
where it is looking for them. according to the website (  
[ODBC Binding for Ruby](http://www.ch-werner.de/rubyodbc/)) it is supposed to be in  
…/ruby/1.8/i386-msvcrt which isn’t particularly helpful. i tried  
IronRuby/Lib/ruby/1.8/i386-msvcrt but unsurprisingly that didnt work.

So how exactly are other IronRubyists using databases? Are they  
struggling  
with deathly slow ADO, is it maybe something my side which is making it  
deathly slow, or is there a way to make an odbc connection to sqlserver?  
I  
would think that most people using IronRuby would want to be connecting  
to  
sqlserver, and not some other database.

Thanks in advance  
Tim Sjoberg

---

<div class="post-metadata">

**Author:** ![Tim\_Sjoberg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@Tim\_Sjoberg](https://www.ruby-forum.com/u/Tim_Sjoberg)\
**Post date:** [May 17, 2010, 6:14pm UTC](https://www.ruby-forum.com/t/ironruby-and-odbc/188743/2 "2010-05-17T18:14:28Z")

</div>

I haven’t experienced that high round-trip time before, but asking on  
the activerecord-sqlserver-adapter list would be best:  
[http://groups.google.com/group/rails-sqlserver-adapter](http://groups.google.com/group/rails-sqlserver-adapter).

As far as using ODBC from IronRuby, the most documented way is to  
download the .NET ODBC Driver (Microsoft.Data.ODBC.dll); simple usage  
from [VB.NET](http://VB.NET) is shown here: [http://support.microsoft.com/kb/310985](http://support.microsoft.com/kb/310985).  
Replacing the C code in ruby-odbc with IronRuby that uses this library  
would be fairly straight-forward. However, I’d suggest figuring out what  
is going on with your existing setup first.

~js

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tim Sjoberg  
Sent: Monday, May 17, 2010 8:48 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] IronRuby and ODBC

Hi

I’m currently running IronRuby (on Rails, in IIS7) on Windows Server  
2008 connecting to SQLServer 2008. As per the guide I am using the  
activerecord-sqlserver-adapter in ADONET mode. It is working fine except  
that it is slower than cancer itself.

I have the same website running on my Laptop (running Ubuntu Linux)  
connecting over LAN to the sqlserver database. For exactly the same page  
the DB time on the page request never goes below 1200ms in ironruby (the  
db is local to this machine), while in linux making an odbc connection,  
to a database database from a different machine, the same page gets as  
low as 60ms for the DB time. Now I don’t believe that the fault lies  
with IronRuby itself, but rather with the db connector.

What I would like to know is how exactly to go about making an odbc  
connection to the database. Currently you need to use ruby-odbc, at  
least activerecord-sqlserver-adapter tries to do it, but its not pure  
ruby and requires compilation. There are precompiled versions but I have  
no idea where it is looking for them. according to the website  
([ODBC Binding for Ruby](http://www.ch-werner.de/rubyodbc/)) it is supposed to be in  
…/ruby/1.8/i386-msvcrt which isn’t particularly helpful. i tried  
IronRuby/Lib/ruby/1.8/i386-msvcrt but unsurprisingly that didnt work.

So how exactly are other IronRubyists using databases? Are they  
struggling with deathly slow ADO, is it maybe something my side which is  
making it deathly slow, or is there a way to make an odbc connection to  
sqlserver? I would think that most people using IronRuby would want to  
be connecting to sqlserver, and not some other database.

Thanks in advance  
Tim Sjoberg
