MS SQL server connection problems


#1

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:inconnect’

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


#2

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:inconnect’

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


#3

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

#4

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.