Forum: Ruby on Rails MS SQL server connection problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Navjeet C. (Guest)
on 2006-01-06 00:45
I am trying to connect to a remote sql server and I am getting the
following error:

c:/ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ADO.rb:57:in `connect': Open
(DBI::Databa
seError)
    OLE error code:80004005 in Microsoft OLE DB Provider for SQL Server
      [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist
or access
 denied.
    HRESULT error code:0x80020009
      Exception occurred.       from
c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:5
84:in `connect'


In my code I am creating a connection using the following code:

ActiveRecord::Base.establish_connection(
    :adapter => "sqlserver",
    :username => "TestUser",
    :password => "TestUser",
    :host => "machine.domain.com",
    :database => "MY_DB,1150")


I can connect to the database from my machine using DBVisualizer, using
the same parameters.

What could be the issue here?

--Navjeet
Navjeet C. (Guest)
on 2006-01-06 01:22
BTW, I was able to connect to the SQL Server by switching mode to ODBC
and creating a DSN on my machine and specifying it in when creating a
connection as below:

ActiveRecord::Base.establish_connection(
    :adapter => "sqlserver",
    :mode => "ODBC",
    :dsn => "my_dsn",
    :username => "TestUser",
    :password => "TestUser",
    :host => "machine.domain.com",
    :database => "MY_DB,1150")

 Not knowing SQL Server too well, it may not supporting ADO access, not
sure.

--Navjeet

Navjeet wrote:
> I am trying to connect to a remote sql server and I am getting the
> following error:
>
> c:/ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ADO.rb:57:in `connect': Open
> (DBI::Databa
> seError)
>     OLE error code:80004005 in Microsoft OLE DB Provider for SQL Server
>       [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist
> or access
>  denied.
>     HRESULT error code:0x80020009
>       Exception occurred.       from
> c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:5
> 84:in `connect'
>
>
> In my code I am creating a connection using the following code:
>
> ActiveRecord::Base.establish_connection(
>     :adapter => "sqlserver",
>     :username => "TestUser",
>     :password => "TestUser",
>     :host => "machine.domain.com",
>     :database => "MY_DB,1150")
>
>
> I can connect to the database from my machine using DBVisualizer, using
> the same parameters.
>
> What could be the issue here?
>
> --Navjeet
Andrew Foster (Guest)
on 2006-01-06 03:43
(Received via mailing list)
Gday,

> >  denied.
> >     HRESULT error code:0x80020009
> >       Exception occurred.       from
> > c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:5
> > 84:in `connect'

Could it be that the remote SQL server currently only uses domain
authentication, explaining why your machine can connect, but won't
accept password-only authentication? I believe this is the default
behaviour. I had a similar issue with a PHP app.

- Andrew
Peter F. (Guest)
on 2006-01-06 05:04
(Received via mailing list)
HI Navjeet,

Your first post appears to be using ADO Ok... you installed the ADO.rb
from
DBI right ?

First, try using :host => "(local)"
Second, try using :host => "machine" instead of machine.domain.com
Third, use SQL Query Analyzer or your other favorite SQL maintenance app
to
test your userid/pw.  The userid/pw is the one that burns me most often,
especially if you have newly created or restored your db.

Any of those ideas work?
--
------------------------------
Joyeux Noël
------------------------------
Peter F.
This topic is locked and can not be replied to.