From: Joey Gibson Date: 2004-10-26T20:43:04+09:00 Subject: Re: DBI with SQL Server Eli Tucker wrote: >Can someone give me a little help with DBI when connecting to SQL >Server? I've dug around a bit, but can't get a simple select statement >to work. Here's what I'm trying: > > > Get the latest rubydbi distribution. Extract the ADO.rb file. Copy it to X:\Ruby\lib\ruby\site_ruby\1.8\DBD\ADO\ADO.rb Then you can do things like this: # Make sure the "dsn =" stuff is all on one line; it may wrap in this email dsn= 'DBI:ADO:Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=test;User Id=sa;Password=password;' DBI.connect(dsn) do |conn| conn.select_all("SELECT * FROM foo") do |row| puts row[:Id] end end Of course this assumes you are on a Windows box. ADO.rb depends on Win32OLE, which (I would assume) only works on Windows. -- She drove a Plymouth Satellite Faster than the Speed of Light... http://www.joeygibson.com/blog http://www.joeygibson.com/blog/life/Wisdom.html Atlanta Ruby User Group http://www.AtlRUG.org