Problem with Sqlserver and Rails on a Win XP

I'm trying to connect to a SQLServer 2008 database running on localhost, but I can't seem to get it working.

Every time I try to run rake db:migrate I get an error telling me that I should install activerecord-sqlserver-adapter:

I have tried to installe ther server-adapter with gem, but it doesn't seems to be working properly.

I struggled with getting SQLServer to work with rails a couple years ago. I can't speak to how easy or hard it is to do recently (sounds just as painful), but here are the steps for how I did it then...they might help. A note about step 2, at the time I used v0.1.0 of ruby- dbi. ADO.rb continued to be included up through v0.2.2 and ADO.rb from that version should still work but I think they stopped supporting ADO after that. I know these steps work with SQLServer 2005, I'm curious to know if this also works with 2008. Also, I seem to remember this only working with Ruby 1.8.6. I have since switched database systems and haven't been motivated enough to figure out SQLServer with newer code.

1. Install SqlServer adapter gem activerecord-sqlserver-adapter (Only works with v1.0.0) 2. Download source distribution of Ruby-DBI from rubyforge.org/ projects/ruby-dbi/ (at the time, I used v0.1.0.   -copy the file lib/dbd/ADO.rb to Ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ ADO.rb                 database.yml file format:     development:       adapter: sqlserver       database: database_name       host: server_name       username: user_name       password: password

Hope this helps, Bob

hi Bob,

Go through this url this will be helpful for you.

http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation—Windows

Magnus D. wrote in post #958686:

I'm trying to connect to a SQLServer 2008 database running on localhost, but I can't seem to get it working.

Advice: do not use MS SQL Server with Rails. Do not do Rails development on Windows. Both of these will make your life harder.

Every time I try to run rake db:migrate I get an error telling me that I should install activerecord-sqlserver-adapter:

[...]

What does your database.yml file look like?

Best,

Marnen Laibow-Koser wrote in post #958814:

Magnus D. wrote in post #958686:

I'm trying to connect to a SQLServer 2008 database running on localhost, but I can't seem to get it working.

Advice: do not use MS SQL Server with Rails. Do not do Rails development on Windows. Both of these will make your life harder.

I'm starting to learn this. :slight_smile:

What does your database.yml file look like?

development:   adapter: sqlserver   mode: odbc   dsn: dsn_name   database: database_name

I have a user dsn connected to the database.

Thanks Magnus

Magnus D. wrote in post #958933:

Marnen Laibow-Koser wrote in post #958814:

Magnus D. wrote in post #958686:

I'm trying to connect to a SQLServer 2008 database running on localhost, but I can't seem to get it working.

Advice: do not use MS SQL Server with Rails. Do not do Rails development on Windows. Both of these will make your life harder.

I'm starting to learn this. :slight_smile:

What does your database.yml file look like?

development:   adapter: sqlserver   mode: odbc   dsn: dsn_name   database: database_name

I have a user dsn connected to the database.

You neglected to specify user and password.

Also, you're using ODBC. I would recommend instead installing TinyTds and using mode: dblib. This allows Rails to make a direct TDS connection to your DB and bypass ODBC entirely.

Thanks Magnus

Best,

Marnen Laibow-Koser wrote in post #959078:

Magnus D. wrote in post #958933:

Marnen Laibow-Koser wrote in post #958814:

Magnus D. wrote in post #958686:

I'm trying to connect to a SQLServer 2008 database running on localhost, but I can't seem to get it working.

Advice: do not use MS SQL Server with Rails. Do not do Rails development on Windows. Both of these will make your life harder.

I'm starting to learn this. :slight_smile:

What does your database.yml file look like?

development:   adapter: sqlserver   mode: odbc   dsn: dsn_name   database: database_name

I have a user dsn connected to the database.

You neglected to specify user and password.

I have tried both with an User DSN and a File DSN, and the User DSN used the login on the system.

Also, you're using ODBC. I would recommend instead installing TinyTds and using mode: dblib. This allows Rails to make a direct TDS connection to your DB and bypass ODBC entirely.

Can I use TinyTds on a Windowsbox? I thought it was Linux-only.

Magnus

Hi Magnus,

I am using MSSQL and like you I had lots of trouble making it work but I finally did get it to work. I am also using XP and here is my Ruby and Rails environment:

ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32] Rails 2.3.5

Here is a list of the steps I took from beginning to end. You might need to change/skip some of the steps. I hope it helps:

1. Install Ruby (1.8.6): Download Ruby 2. Install rubygems:    a. Download RubyGems | RubyGems.org | your community gem host (zip version)    b. Unpack to a directory and cd there    c. ruby setup.rb 3. Install rails: gem install rails –v=2.3.5 4. Install mongrel: gem install mongrel 5. Install mongrel service: gem install mongrel_service 6. Install SQL Server adapter: gem install activerecord-sqlserver- adapter 7. Install ODBC gem: gem install odbc-rails 8. Install SQL Server Management utility (from Microsoft) 9. Create SQL Server DB (name 'give it a name here') 10. Create login in SQL Server ('give it a name here') 11. Create DB user ('give it a name here') 12. Create DSN in Windows:    a. Control Panel -> Adminstrative Tasks -> Data Sources (ODBC)    b. Click on System DSN -> Add    c. Select type SQL Server       i. Name: 'give it a name here'       ii. Description: 'give it a name here'       iii. Server: Server name (i.e.: 'Whatever name the DB has under SQL Server Manangement here')       iv. Use SQL Authentication

A bit OT, but seeing as you mentioned it, as a Windows user that has recently migrated my Rails apps to a Linux box, I can confirm what I have frequently read on this group: Rails and Linux > Rails and Windows.

I was brand new to Linux, and got everything up and running in no time compared with my original struggles on Windows, and it looks like a far better OS. If you haven't yet made the jump, I would recommend it.

Best

Paul

(Linux convert)

pepe wrote in post #959313:

You might be better to throw Windows out of your computer rather than the computer out of the window.

Colin

I'm now trying to reinstall ruby on my computer, and if that doesn't work, I'm thinking about throwing it out the window.

Magnus

In a few months I would like to be where Paul is at and pretty much every day of my life I feel like doing what Colin is suggesting. :wink:

pepe