# Problems with dbi to sql server

**URL:** <https://www.ruby-forum.com/t/problems-with-dbi-to-sql-server/115833>\
**Category:** Ruby\
**Created:** [September 28, 2007, 10:50pm UTC](https://www.ruby-forum.com/t/problems-with-dbi-to-sql-server/115833 "2007-09-28T22:50:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 28, 2007, 10:50pm UTC](https://www.ruby-forum.com/t/problems-with-dbi-to-sql-server/115833/1 "2007-09-28T22:50:42Z")

</div>

I’m trying to figure out how to connect to sql server (2005 i think)

this program here, at first used to show the defaukt stuff, ODBC I  
think.

DBI.available\_drivers.each do |drv|  
puts drv  
DBI.data\_sources(drv).each do |src|  
puts " #{src}"  
end  
end

then I did the config/setup/install with config as shown below for the  
dbi stuff I downloaded:

C:\ruby-sql\ruby-dbi\>ruby setup.rb config –  
with=dbi,dbd\_ado,dbd\_odbc,dbd\_msql,d  
bd\_mysql,dbd\_oracle  
entering config phase…  
config done.

now the original script above shows nothing, though I see what look  
like drivers in a subdirectory called dbd off of my ruby lib and the  
following call gives the error shown below:

dbh =  
DBI.connect(‘dbi:ODBC:’+‘%q{DRIVER=SQLServer;[SERVER=me.my.com](http://SERVER=me.my.com);DATABASE=techie;Uid=me;Pwd=\*mypass}’)

c:/ruby/lib/ruby/site\_ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect': IM002 (0) [Micr osoft][ODBC Driver Manager] Data source name not found and no default driver spe cified (DBI::DatabaseError) from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:424:in `connect’  
from c:/ruby/lib/ruby/site\_ruby/1.8/dbi.rb:215:in `connect’  
from C:/rb-play/tst.rb:19

C:\rb-play\>

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 29, 2007, 4:13am UTC](https://www.ruby-forum.com/t/problems-with-dbi-to-sql-server/115833/2 "2007-09-29T04:13:17Z")

</div>

removed\_email\_address@domain.invalid wrote:

> I’m trying to figure out how to connect to sql server (2005 i think)

I regularly use ADO to connect to SQL Server databases:

> **[Ruby, ADO, and SQLServer](http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html)**
>
> Ruby and ActiveX Data Objects (ADO) make working with Microsoft SQL Server databases simple. Here's a simple example of a class that manages...

David

> **[Ruby on Windows](http://rubyonwindows.blogspot.com)**
>
> On using the Ruby programming language on the Microsoft Windows platform
