Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Connecting to SQL Server 2005

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}")

like image 229
jtruelove Avatar asked Sep 20 '26 21:09

jtruelove


1 Answers

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

like image 122
jtruelove Avatar answered Sep 22 '26 16:09

jtruelove



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!