# Ruby and microsoft sql server

**URL:** <https://rubytalk.org/t/ruby-and-microsoft-sql-server/36821>\
**Category:** ruby-talk\
**Created:** [10 April 2007 16:05 UTC](https://rubytalk.org/t/ruby-and-microsoft-sql-server/36821 "2007-04-10T16:05:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulo\_Geyer](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@Paulo\_Geyer](https://rubytalk.org/u/Paulo_Geyer)\
**Post date:** [10 April 2007 16:05 UTC](https://rubytalk.org/t/ruby-and-microsoft-sql-server/36821/1 "2007-04-10T16:05:05Z")

</div>

hi, anyone here has experience with microsoft sql server?  
i did this little program:

#!/usr/bin/env ruby

require 'dbi'  
conn = DBI.connect('DBI:ODBC:jornaldedebates', 'sa', 'fodase')  
puts conn.tables

but when i try to run it, i get this error:  
paulo@shuffle:~/Desktop/tmp/sql$ ./dbi.rb  
/usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect': IM003 (0) [iODBC]  
[Driver Manager]Specified driver could not be loaded  
(DBI::DatabaseError)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from ./dbi.rb:4

any ideas?

---

<div class="post-metadata">

**Author:** ![Huw\_Collingbourne1](https://avatars.discourse-cdn.com/v4/letter/h/34f0e0/32.png) [@Huw\_Collingbourne1](https://rubytalk.org/u/Huw_Collingbourne1)\
**Post date:** [10 April 2007 16:50 UTC](https://rubytalk.org/t/ruby-and-microsoft-sql-server/36821/2 "2007-04-10T16:50:09Z")

</div>

"Paulo Geyer" \<paulogeyer@gmail.com\> wrote in message  
news:1176220821.796950.49200@y80g2000hsf.googlegroups.com...

> hi, anyone here has experience with microsoft sql server?

Are you using ADO.rb?

I wrote a tutorial on using SQL Server for Rails development with Ruby In  
Steel here:

[http://www.sapphiresteel.com/Using-SQL-Server-With-A-Rails](http://www.sapphiresteel.com/Using-SQL-Server-With-A-Rails)

Naturally, the tutorial includes much that is specific to Ruby In Steel.  
However, it may also give you some help on using SQL Server and Ruby in  
general.

best wishes  
Huw Collingbourne

[http://www.sapphiresteel.com](http://www.sapphiresteel.com)  
Ruby Programming In Visual Studio 2005

---

<div class="post-metadata">

**Author:** ![Stefan\_Schmiedl](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Stefan\_Schmiedl](https://rubytalk.org/u/Stefan_Schmiedl)\
**Post date:** [10 April 2007 17:15 UTC](https://rubytalk.org/t/ruby-and-microsoft-sql-server/36821/3 "2007-04-10T17:15:05Z")

</div>

verify that your linux (presumably) based ODBC setup is working correctly.  
Since you're connecting to MSSQL you'll probably have an installation of  
FreeTDS lying around, which needs to be correctly configured, too.

There are console tools for both components which can be used to put the  
finger on the failing link in the chain.

ruby - dbi - odbc -- unixODBC - freetds -- network -- mssql

The error message tells me that you're reaching odbc from the left,  
I also assume that you can actually connect via TCP/IP with the given  
authentication data to MSSQL and that you can ping the Windows box.  
But there are still two possible points of failure left.

HTH  
s.

> **···**
>
> On Tue, 10 Apr 2007 09:00:21 -0700, Paŭlo Geyer wrote:
> 
> > hi, anyone here has experience with microsoft sql server? i did this  
> > little program:
> > 
> > #!/usr/bin/env ruby
> > 
> > require 'dbi'  
> > conn = DBI.connect('DBI:ODBC:jornaldedebates', 'sa', 'fodase') puts  
> > conn.tables
> > 
> > but when i try to run it, i get this error:  
> > paulo@shuffle:~/Desktop/tmp/sql$ ./dbi.rb  
> > /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect': IM003 (0) [iODBC]  
> > [Driver Manager]Specified driver could not be loaded  
> > (DBI::DatabaseError)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/lib/ruby/1.8/dbi.rb:424:in `connect' from  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/lib/ruby/1.8/dbi.rb:215:in `connect' from ./dbi.rb:4
> > 
> > any ideas?
