views:

41

answers:

1

I'm trying to connect Rails to SQL Server. I installed the activerecord-sqlserver-adapter and ruby-odbc gems, but I'm not sure what to put in my database.yml file.

What exactly is a DSN, and why do I need it? (Is this some windows-specific thing?)

What do I do if I want to use Windows Authentication, instead of specifying a username and password?

I tried creating a DSN, specifying Windows NT authentication, and put the following in my config.yml:

development:
  adapter: sqlserver
  dsn: myDsn
  mode: odbc

but I get a "The specified DSN contains an architecture mismatch between the Driver and Application" error. [I tried creating the DSN from Windows/system32/odbcad32.exe as well, since a Google search said this would create a 32-bit DSN instead, but I get the same error.]

Am I missing something in my database.yml file?

UPDATE: I tried using

development:
  adapter: sqlserver
  mode:odbc
  dsn: Provider=SQLOLEDB; Data Source=.\SQLEXPRESS; Integrated Security=SSPI

but I get a "Data source name not found and no default driver specified" error. Is it possible my Provider is not SQLOLEDB? [I don't know what a provider is or how to figure out what it's supposed to be -- I just copied it from another connection string I found.] I do know that I can connect to .\SQLEXPRESS using Windows Authentication from my actual SQL Server Management Studio program.

A: 

A DSN is a "Database Source Name." It contains the information that an ODBC driver needs to connect to a specific database.

Perhaps this SO Q&A will help you: Connect rails application to SQL Server 2005 from Windows

Also see connectionstrings.com for general help with connection strings.

Joe Stefanelli