Help with connecting to SQL Server 2005 Database with Ruby

I am quite new to ruby and trying to connect to a SQL Server 2005
Database with ruby to run a few queries but I am not getting anywhere.
Am I missing something? I am getting a connection refused on all counts.

I have installed the following gems: DBI,WIN32OLE,SEQUEL

Below are some of the strings that I have tried to use

db=Sequel.connect([email protected], [email protected], [email protected],
[email protected])

db = Sequel.connect(‘postgres://username:[email protected]/database’)

db=DBI.connect(“DBI:ADO:Provider=SQLNCLI;Data Source=hostdb;Initial
Catalog=dbase;username=username;pword=password”)

db=DBI.connect(“DBI:ODBC:Driver={SQLServer};Server=hostdb;Database=dbase;Uid=username;Pwd=password”)

db=DBI.connect(‘DBI:ODBC:hostdb’,[email protected],Data
[email protected],[email protected],[email protected])

db=DBI.connect(“DBI:OLEDB:Provider=sqloledb;Data [email protected];Initial
[email protected];User [email protected];[email protected]”)

On Wed, May 6, 2009 at 4:04 PM, Arti S. [email protected]
wrote:

I am quite new to ruby and trying to connect to a SQL Server 2005
Database with ruby to run a few queries but I am not getting anywhere.
Am I missing something? I am getting a connection refused on all counts.

Try this if you’re using sequel:

DB = Sequel.ado(‘database_name’, :host => ‘localhost’, :user =>
‘username’,
:password => ‘password’)

Should work if you replace the ‘database_name’, host, user and password
with
your own.

Ben

Thank you Ben. This works now.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs