Connect rails application to SQL Server 2005 from Windows

Posted by Enrico Carlesso on Stack Overflow See other posts from Stack Overflow or by Enrico Carlesso
Published on 2010-04-16T07:37:29Z Indexed on 2010/04/18 9:43 UTC
Read the original article Hit count: 546

Hi guys.

I (sadly) have to deploy a rails application on Windows XP which has to connect to Microsoft SQL Server 2005.

Surfing in the web there are a lot of hits for connect from Linux to SQL Server, but cannot find out how to do it from Windows.

Basically I followed these steps:

  • Install dbi gem
  • Install activerecord-sql-server-adapter gem

My database.yml now looks like this:

development:
  adapter: sqlserver
  mode: odbc
  dsn: test_dj
  host: HOSTNAME\SQLEXPRESS
  database: test_dj
  username: guest
  password: guest

But I'm unable to connect it. When I run rake db:migrate I get

IM002 (0) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I'm not a Windows user, so cannot understand really well the meaning of dsn element or so. Does someone have an idea how to solve this?

Thanks in advance


With Alexander tips now I've modified my database.yml to:

development:
  adapter: sqlserver
  mode: odbc
  dsn: Provider=SQLOLEDB;Data Source=SCADA\SQLEXPRESS;UID=guest;PWD=guest;Initial Catalog=test_dj;Application Name=test

But now rake db:migrate returns me:

S1090 (0) [Microsoft][ODBC Driver Manager] Invalid string or buffer length

Am I missing something?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about sql-server-2005