# Ruby | Ruby on Rails | database MS SQL Server 2005

**URL:** <https://www.ruby-forum.com/t/ruby-ruby-on-rails-database-ms-sql-server-2005/115537>\
**Category:** Ruby\
**Created:** [September 26, 2007, 2:40am UTC](https://www.ruby-forum.com/t/ruby-ruby-on-rails-database-ms-sql-server-2005/115537 "2007-09-26T02:40:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erstwhileiii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9adbd/32.png) [@erstwhileiii](https://www.ruby-forum.com/u/erstwhileiii)\
**Post date:** [September 26, 2007, 2:40am UTC](https://www.ruby-forum.com/t/ruby-ruby-on-rails-database-ms-sql-server-2005/115537/1 "2007-09-26T02:40:49Z")

</div>

How can I configure Ruby and Ruby on Rails for use with MS SQL Server  
2005?

Environment:

- Ruby 1.8.6-25 (windows)
- Ruby on Rails 1.2.3
- ruby-dbi 0.1.1 (installed with dbi,dbd\_ado)
- OS: Windows XP Professional sp4
- Database: MS SQL Server Express 2005 (bonus and on MS SQL Server

1. 

I have attempted to use the following definitions:

development:  
adapter: sqlserver  
database: event\_development  
username: sa  
password: password  
host: DBI:ADO:Provider=SQLNCLI;Data Source=localhost;Initial  
Catalog=event\_development;User Id=sa;Password=password;

development:  
adapter: sqlserver  
database: event\_development  
username: sa  
password: password  
host: localhost

development:  
adapter: sqlserver  
database: event\_development  
username: sa  
password: password  
host: localhost  
mode: DBI:ADO  
provider: SQLNCLI

Any help will be appreciated!

---

<div class="post-metadata">

**Author:** ![erstwhileiii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9adbd/32.png) [@erstwhileiii](https://www.ruby-forum.com/u/erstwhileiii)\
**Post date:** [September 26, 2007, 6:58am UTC](https://www.ruby-forum.com/t/ruby-ruby-on-rails-database-ms-sql-server-2005/115537/2 "2007-09-26T06:58:05Z")

</div>

Hi Joe,

Erstwhile Joe wrote:

> How can I configure Ruby and Ruby on Rails for use with MS SQL Server  
> 2005?

I haven’t used ADO but have been successfully using ODBC to connect to a  
mssql server. This is how I created the connection:

ActiveRecord::Base.establish\_connection( :adapter =\> ‘sqlserver’,  
:mode =\> ‘odbc’,  
:dsn =\> ‘MyDSName’,  
:username =\> ‘bob’,  
:password =\> ‘bob’)

I added bob as a local user (maybe domain users also work) and created  
the ODBC connection called MyDSName.

Cheers,  
Mark

---

<div class="post-metadata">

**Author:** ![erstwhileiii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9adbd/32.png) [@erstwhileiii](https://www.ruby-forum.com/u/erstwhileiii)\
**Post date:** [September 27, 2007, 7:25am UTC](https://www.ruby-forum.com/t/ruby-ruby-on-rails-database-ms-sql-server-2005/115537/3 "2007-09-27T07:25:45Z")

</div>

On Sep 26, 9:57 am, Mark G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> :mode => 'odbc',
> :dsn => 'MyDSName',
> :username => 'bob',
> :password => 'bob')
> 
> ```
> 
> I added bob as a local user (maybe domain users also work) and created  
> the ODBC connection called MyDSName.
> 
> Cheers,  
> Mark

hi  
Can you kindly helpo me more on this.

I am using sql2005 express on my machine.

My server name is : RubyGujarat  
username:- sa  
password:- mytest

can you help me , how should i mention this in the code given by you  
above.

Thanks

IronRuby

---

<div class="post-metadata">

**Author:** ![erstwhileiii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9adbd/32.png) [@erstwhileiii](https://www.ruby-forum.com/u/erstwhileiii)\
**Post date:** [September 27, 2007, 10:48am UTC](https://www.ruby-forum.com/t/ruby-ruby-on-rails-database-ms-sql-server-2005/115537/4 "2007-09-27T10:48:46Z")

</div>

unknown wrote:

> On Sep 26, 9:57 am, Mark G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ```
> > :mode => 'odbc',
> > :dsn => 'MyDSName',
> > :username => 'bob',
> > :password => 'bob')
> > 
> > ```
> > 
> > I added bob as a local user (maybe domain users also work) and created  
> > the ODBC connection called MyDSName.
> > 
> > Cheers,  
> > Mark
> 
> hi  
> Can you kindly helpo me more on this.
> 
> I am using sql2005 express on my machine.
> 
> My server name is : RubyGujarat  
> username:- sa  
> password:- mytest
> 
> can you help me , how should i mention this in the code given by you  
> above.
> 
> Thanks
> 
> IronRuby

development:

# adapter: mssqlclient

adapter: sqlserver  
database: mydb  
host: localhost # or [myhost.at.com](http://myhost.at.com)  
username: myName  
password: myPwd  
charset: unicode

This was my configuration back when I was testing some stuff. My problem  
was that all number type fields (real, double, fix…) were returned as  
null and it was useless for me.

You can also try mssqlclient.

by  
TheR
