views:

404

answers:

2

I want to connect to a sql server 2005/db with ODBC through ruby using windows authentication. I have the gems dbi-0.4.1 and dbd-odbc-0.2.4 installed. What do I need to do for a connection string? So far I haven't been able to get it to work.

DBI.connect("DBI:ODBC:Data Source=#{server};Integrated Security=SSPI;Initial Catalog=#{db}")

A: 

I've successfully connected to a test database with just:

DBI.connect('DBI:ODBC:test')

Dave McLaughlin
What about a server db pair? Do you have any permissioning setup, are you sure it's really auto authenticating with your credentials?
Jeremy T
Hmm, good question! I can't investigate it just now, but I'll get back to it next week.I'm not that familiar with MS SQL myself, just evaluating it for a project against MySQL (which is more familiar). Thanks for the pointer.
Dave McLaughlin
+1  A: 

It appears after you specify DBI:DriverName: you can put whatever connection info you need

DBI.connect("DBI:ODBC:Driver={SQL Server};Server=#{server};Database=#{db};Trusted_Connection=yes")

http://www.devlist.com/ConnectionStringsPage.aspx

Jeremy T
How would this translate into a yml config file? I have a similar issue w/ a Rails application.
catalpa