Trubelshooting MS Sql database connection

Hello i have been atempting to move a project from sqlite database to
a sql server database with absolutly no success. i am now going to
document my entire process so that mabey someone can se the error of
my ways. And if some one else has this problem this migth act as a
troubleshooting guide.

OS: windows server 2003 latest sp
Sql: Sql server 2008

  1. Install ruby 192.p0 from http://rubyinstaller.com/downloads (ticked
    both boxes ie add to PATH and associate files)
    installation folder is c:/ruby192

2.Install rails via
“gem install rails”

  1. Install mongrel via
    “gem install mongrel --pre”

  2. install the sql adapter via
    “gem install activerecord-swlserver-adapter”

  3. install dbd-odbc via
    “gem install dbd-odbc”
    this also installed the dbi gem so i wont install this from a separate
    command

Ok now everything i need to start RoR with mongrel and Sql Server
should be installed as far as i know on to the gem file

gem ‘rails’#, ‘3.0.1’

require ‘activerecord-sqlserver-adapter’
gem ‘mongrel’, ‘1.2.0.pre2’
require ‘dbi’

and then the database.yml

development:
adapter: sqlserver
mode: odbc
database: NameOfMyDB
host: localhost
dsn: name_of_my_db
autocommit: true
username: something
password: something

Notes about this conf
dsn is the same name as the dsn i created with the odbc data source
administrator tool this is a system DSN by the way i have also tried
with file DSN

Ok now on to running my app

i go to the directory wich is located as follows

D:/projects/railsdev/projectname/

so i go there and execute
bundle install the result of this is
Error require: no such file to load --activerecord-sqlserver-adapter

if i change my require to a gem command everything is installed and
the server starts when i try to connect to the database i get another
error LoadError (no such file to load --odbc)

i have been loosing sleep over this please tell me what am i doing
wrong ?

On Tue, Oct 26, 2010 at 5:41 AM, Fredrik TiC Jansson <
[email protected]> wrote:

both boxes ie add to PATH and associate files)

require ‘activerecord-sqlserver-adapter’
dsn: name_of_my_db

error LoadError (no such file to load --odbc)

[email protected][email protected]

.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

take a look at
http://www.10pines.com/content/deploy-ruby-rails-windows-2008-server-and-iis-70

greets

http://www.rodolinux.com.ar

“I must not fear. Fear is the mind-killer. I will face my fear. I will
permit it to pass over me and through me. And when it has gone past I
will
turn the inner eye to see its path. Where the fear has gone there will
be
nothing. Only I will remain.” - Bene Geserit’s Fear Lethany - Dune
Trilogy -
Frank Herbert

Thanks seems rather comprehensive i will go through your tutorial.

It’s not my tutorial. Just I found it some days ago

On Tue, Oct 26, 2010 at 9:41 AM, Fredrik TiC Jansson <
[email protected]> wrote:

document my entire process so that mabey someone can se the error of
2.Install rails via
this also installed the dbi gem so i wont install this from a separate

password: something
D:/projects/railsdev/projectname/
wrong ?

"I must not fear. Fear is the mind-killer. I will face my fear. I will
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to

[email protected][email protected]

.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


http://www.rodolinux.com.ar

“I must not fear. Fear is the mind-killer. I will face my fear. I will
permit it to pass over me and through me. And when it has gone past I
will
turn the inner eye to see its path. Where the fear has gone there will
be
nothing. Only I will remain.” - Bene Geserit’s Fear Lethany - Dune
Trilogy -
Frank Herbert

I finally got it working after a lot of googeling around big thanks
to
http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation---Windows
for pointing me towards ruby-odbc which was the final peice to solve
my puzzle

How to get Ruby on Rails working with MS SQLServer2008 and windows
server 2003
This mini tutorial assumes MS SQLServer2008 is installed and running i
will be using mongrel to deploy

  1. Install ruby via www.rubyinstaller.org (i used 1.8.7 version)
  2. Install the DevKit (otherwise all gems wont install properly)
  3. Start a command promt with ruby via the start menu
  4. Install rails
    gem install rails
  5. Get a cup of coffee this will take a while
  6. install mongrel
    gem install mongrel --pre (2010-10-27 this was the way to do it, this
    will change)
  7. install ruby-odbc
    gem install ruby-odbc
  8. install activerecord-sqlserver-adapter
    gem install activerecord-sqlserver-adapter
  9. install dbi
    gem install dbi
  10. install rails-dbi
    gem install rails-dbi
    NOTE: the reason for installing rails dbi and putting gem ‘rails-
    dbi’, :require => ‘dbi’ in the gem file
    is a conflict with the dbi and the deprecated gems. This issue migth
    be resolved in the future.
  11. Now its time to get on with editing our gemfile

put this in it

gem ‘rails-dbi’, :require => ‘dbi’
gem ‘ruby-odbc’
gem ‘activerecord-sqlserver-adapter’
gem ‘mongrel’, ‘1.2.0.pre2’ #this line will probably change in the
future this is written 2010-10-27

Then you need a connection string this will be in your config/
database.yml file

development:
adapter: sqlserver
driver: Sql Client
mode: odbc
database: DatabaseName
host: localhost/SQLSERVER2008
dsn: dsn_name
autocommit: true
username: user
password: pass

NOTE:

localhost migth suffice or if you have mutilple named instances like

me you have to include that as well
About dsn:
the dsn is created via the Data Sources(ODBC) tool under
administrative tools
Create a System DSN with the same name as dsn: dsn_name under client
configuration use TCP/IP(this should be default just adding this so
you know that this is correct)

now try to create a new project and a scaffold do a bundle install and
rake db:migrate if all went well you should be able to start your
server via rails server and start doing som CRUD against your
SQLServer2008 database

I finally got it working after a lot of googeling around big thanks
to
http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation---Windows
for pointing me towards ruby-odbc which was the final peice to solve
my puzzle

How to get Ruby on Rails working with MS SQLServer2008 and windows
server 2003
This mini tutorial assumes MS SQLServer2008 is installed and running i
will be using mongrel to deploy

  1. Install ruby via www.rubyinstaller.org (i used 1.8.7 version)
  2. Install the DevKit (otherwise all gems wont install properly)
  3. Start a command promt with ruby via the start menu
  4. Install rails
    gem install rails
  5. Get a cup of coffee this will take a while
  6. install mongrel
    gem install mongrel --pre (2010-10-27 this was the way to do it, this
    will change)
  7. install ruby-odbc
    gem install ruby-odbc
  8. install activerecord-sqlserver-adapter
    gem install activerecord-sqlserver-adapter
  9. install dbi
    gem install dbi
  10. install rails-dbi
    gem install rails-dbi
    NOTE: the reason for installing rails dbi and putting gem ‘rails-
    dbi’, :require => ‘dbi’ in the gem file
    is a conflict with the dbi and the deprecated gems. This issue migth
    be resolved in the future.
  11. Now its time to get on with editing our gemfile

put this in it

gem ‘rails-dbi’, :require => ‘dbi’
gem ‘ruby-odbc’
gem ‘activerecord-sqlserver-adapter’
gem ‘mongrel’, ‘1.2.0.pre2’ #this line will probably change in the
future this is written 2010-10-27

Then you need a connection string this will be in your config/
database.yml file

development:
adapter: sqlserver
driver: Sql Client
mode: odbc
database: DatabaseName
host: localhost/SQLSERVER2008
dsn: dsn_name
autocommit: true
username: user
password: pass

NOTE:

localhost migth suffice or if you have mutilple named instances like

me you have to include that as well
About dsn:
the dsn is created via the Data Sources(ODBC) tool under
administrative tools
Create a System DSN with the same name as dsn: dsn_name under client
configuration use TCP/IP(this should be default just adding this so
you know that this is correct)

now try to create a new project and a scaffold do a bundle install and
rake db:migrate if all went well you should be able to start your
server via rails server and start doing som CRUD against your
SQLServer2008 database

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