Connecting to MSSQL with Ruby on Ubuntu

Hello friends,

I tried to connect MSSql with Ruby on Ubuntu follow this
linkhttp://lambie.org/2008/02/28/connecting-to-an-mssql-database-from-ruby-on-ubuntu/
its
working nice. But i tried with Sequel.connect method connection was
established but try to fetching data following error was raised

irb(main):035:1> DB.synchronize do |conn|
irb(main):035:1> end

Sequel::DatabaseConnectionError: ODBC::Error: IM002 (0)
[unixODBC][Driver
Manager]Data source name not found, and no default driver specified

Please give suggestions to resolve this error.

Thanks & Regards,

Dhamodharan N

On Wed, Apr 20, 2011 at 1:24 AM, DHAMODHARAN N [email protected]
wrote:

Manager]Data source name not found, and no default driver specified

Please post your code of how you are making the connection.

Thanks,
B.

Hello **Bryan Crosslan,

*configured. Initially i can able to access through dbi but now its
arise same error. *

In irb

Trying with Sequel:

  • irb(main):001:0>*

irb(main):001:0> require “rubygems”

=> true

irb(main):002:0> require “sequel_core”

=> true
irb(main):003:0> require “odbc”
=> true

irb(main):004:0> db = Sequel.odbc(“dbname”,
:uid=>“username”,:pwd=>“password”,:driver=>’{FreeTDS}’)

=> #<Sequel::ODBC::Database: “odbc:/dbname”>

irb(main):005:0> result=db[“select * form tblCountry”]

=> #<Sequel::ODBC::Dataset: “select * form tblCountry”>

irb(main):006:0> result.map {|r| puts r.inspect}

Sequel::DatabaseConnectionError: ODBC::Error: INTERN (0)
[RubyODBC]Cannot allocate SQLHENV

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:35:in
`initialize’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:35:in
`new’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:35:in
`connect’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/database/misc.rb:45

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool.rb:92:in
`call’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool.rb:92:in
`make_new’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:126:in
`make_new’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:112:in
`available’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:102:in
`acquire’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:146:in
`sync’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:146:in
`synchronize’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:146:in
`sync’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:101:in
`acquire’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:74:in
`hold’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/database/connecting.rb:226:in
`synchronize’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:49:in
`execute’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:541:in
`execute’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:91:in
`fetch_rows’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:123:in
`each’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:342:in
`map’

from
/usr/lib/ruby/gems/1.8/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:342:in
`map’

from (irb):6
from
/usr/local/lib/site_ruby/1.8/rubygems/exceptions.rb:4irb(main):007:0>

Trying with dbi:

irb(main):001:0> require “dbi”

=> true

irb(main):002:0> db=DBI.connect(“dbi:ODBC:dbname”,‘username’,‘password’)

DBI::DatabaseError: INTERN (0) [RubyODBC]Cannot allocate SQLHENV

from /usr/lib/ruby/1.8/dbd/odbc/driver.rb:36:in `connect’

from /usr/lib/ruby/1.8/dbi/handles/driver.rb:33:in `connect’

from /usr/lib/ruby/1.8/dbi.rb:148:in `connect’
from (irb):2

from /usr/lib/ruby/1.8/i486-linux/rbconfig.rb:170

irb(main):003:0>

On Thu, Apr 21, 2011 at 7:01 AM, DHAMODHARAN N [email protected]
wrote:

Have you tried this fix?

http://stackoverflow.com/questions/1419397/rubyodbc-cannot-allocate-sqlhenv

B.

Hello **Bryan Crosslan,

   In my system Ubuntu lucid 10.04 in this system unixodbc debian

package installation not installed properly because of incomplete setup
files. Otherwise its will working fine.

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