ActiveRecord connect to SqlServer

D

dkmd_nielsen

I know you guys have beaten this subject to death, but I'm just not
getting a connection to SqlServer 2005. It is installed locally, with
an instance name of DVN-P548. I use my windows user name and password
to log in.

require 'rubygems'
require_gem 'activerecord'

ActiveRecord::Base.establish_connection(
:adapter => 'sqlserver',
:mode => 'ADO',
:host => 'P548-DVN',
:dsn => '???', ** what is this supposed
to be???
:database => 'CountsAAN',
:username => 'my_windows_userid',
:password => 'my_password'
)

class WiRecord < ActiveRecord::Base
end

Errors I get returned are either "Server does not exist or access is
denied" (thanks, MS, for narrowing this one down a bit), or "user is
not trusted", depending on what values I have attempted for host and
dsn. What is host and dsn? Believe it or not, I do not find a clear
definition in the rails handbook.

Do I want to use ADO, or should I use ODBC? If odbc, where does one
find the connection string? Being a windows user, I'm so used to
having everything done for me under the covers that I don't understand
any of the underlying details.

Thanks for everything,
dvn
 
D

dkmd_nielsen

ActiveRecord::Base.establish_connection(
:adapter => 'sqlserver',
:mode => 'ADO',
:host => 'DVN-P548',
:dsn => 'LocalSqlServer2005',
:database => 'CountsAAN',
:username => 'my_username',
:password => 'my_password'
)

The above configuration yields a Login failed for user. I've
confirmed through Windows Services that my user name and password are
valid for logging into my server instance. I've tried user name in
the formats of "my_username" and "domain\my_username", and both fail
with the same error: "Login failed for user 'my_username'. HRESULT
error code:0x80020009". So I'm at a loss. I don't know what else to
check.
 
T

Todd Benson

I know you guys have beaten this subject to death, but I'm just not
getting a connection to SqlServer 2005. It is installed locally, with
an instance name of DVN-P548. I use my windows user name and password
to log in.

require 'rubygems'
require_gem 'activerecord'

ActiveRecord::Base.establish_connection(
:adapter => 'sqlserver',
:mode => 'ADO',
:host => 'P548-DVN',

Why is this not DVN-P548?
:dsn => '???', ** what is this supposed
to be???

You shouldn't need that part of the Hash. Try leaving the :dsn part out.
:database => 'CountsAAN',
:username => 'my_windows_userid',
:password => 'my_password'
)

class WiRecord < ActiveRecord::Base
end

Errors I get returned are either "Server does not exist or access is
denied" (thanks, MS, for narrowing this one down a bit), or "user is
not trusted"

That last error is a bit weird. That means you're connecting to
something, but failing. Maybe look at your permissions?
, depending on what values I have attempted for host and
dsn. What is host and dsn? Believe it or not, I do not find a clear
definition in the rails handbook.

"host" is the name of the machine you are running the database on.
This can also be an IP address. If the database is on the same
machine, use 127.0.0.1 or localhost.
Do I want to use ADO, or should I use ODBC? If odbc, where does one
find the connection string? Being a windows user, I'm so used to
having everything done for me under the covers that I don't understand
any of the underlying details.

Hopefully somebody else can answer this.
Thanks for everything,
dvn

Todd
 
D

Dejan Dimic

Why is this not DVN-P548?


You shouldn't need that part of the Hash. Try leaving the :dsn part out.




That last error is a bit weird. That means you're connecting to
something, but failing. Maybe look at your permissions?


"host" is the name of the machine you are running the database on.
This can also be an IP address. If the database is on the same
machine, use 127.0.0.1 or localhost.




Hopefully somebody else can answer this.


Todd

You can make a User DSN throughout ODBC Data Source Administrator for
example named MyExpressDB using SQL Native Client driver.

Then your connection settings should be:

ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:mode => "ODBC",
:dsn => "MyExpressDB"
)

and sit back and enjoy
 
D

dkmd_nielsen

You can make a User DSN throughout ODBC Data Source Administrator for
example named MyExpressDB using SQL Native Client driver.

Then your connection settings should be:

ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:mode => "ODBC",
:dsn => "MyExpressDB"
)

and sit back and enjoy

Thanks to all. I setup the ODBC connection and it is working
perfectly. All I did was change the :mode to "ODBC", and that was it.

dvn
 
P

Paul Rogers

Why is this not DVN-P548?


You shouldn't need that part of the Hash.  Try leaving the :dsn part out..




That last error is a bit weird.  That means you're connecting to
something, but failing.  Maybe look at your permissions?


"host" is the name of the machine you are running the database on.
This can also be an IP address.  If the database is on the same
machine, use 127.0.0.1 or localhost.




Hopefully somebody else can answer this.


Todd

I think this error "Server does not exist or access is
denied" (thanks, MS, for narrowing this one down a bit), or "user is
not trusted" means you are trying to access a sql server that is
domain authenticated by supplying a sql server authenticated user

Also, when I used ado some time back with rails I got lots of errors,
but switching to odbc mae it work fine.

Paul
 
S

Softmind Technology

@ DVN

Thanks for this thread and thanks to others who helped him.

I would request you to kindly paste here the complete configuration file
( YAML) along with the SQL driver installation and its location.

Your single file with full details shall help many many developers, who
are facing same problem like you, including me.

Since the above codes are all mixed up, a single paste with full details
shall be an wonderful idea.

I hope you will help us.

Thanks

SoftMind.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top