2011-03-03 53 views
3

我想開發一個使用MS SQL Express的RoR應用程序,但我無法弄清楚如何連接到數據庫。我試圖Ruby on Rails和MS SQL EXPRESS

development: 
adapter: sqlserver 
database: historicDB 
username: dxt 
password: dxt 
host: DBI:ADO:Provider=SQLNCLI;Data Source=localhost\SQLEXPRESS;InitialCatalog=historicDB;User Id=dxt;Password=dxt; 

development: 
adapter: sqlserver 
database: historicDB 
host: localhost\SQLEXPRESSS 
username: dxt 
password: dxt 

我也裝DBI,DBD-ODBC,ActiveRecord的 - SQLSERVER適配器,但now​​thing作品我總是

ActiveRecord::ConnectionNotEstablished 

在歡迎屏幕上

+0

http://stackoverflow.com/questions/67141/using-rails-2-x-with-ms-sql-server-2005 – 2011-03-03 13:27:41

回答

0

我沒有使用這個與上面顯示的完全相同的配置,但是這個鏈接可能有所幫助:http://rob-rowe.blogspot.com/2010/10/getting-rails-3-up-on-windows.html

+0

你是如何設法安裝Development Kid的?我運行紅寶石dk.rb init,它發現我的安裝目錄,然後我運行紅寶石dk.rb安裝,它看起來它安裝,但當我嘗試安裝任何東西我得到一個錯誤,需要構建工具沒有安裝 – 2011-03-03 14:13:54

+0

我遵循這些指示:https://github.com/oneclick/rubyinstaller/wiki/Development-Kit專門的第4部分。在我這樣做後,我能夠得到它的工作。 – Rob 2011-03-03 14:38:35

+0

我做了同樣的事情,但第5部分失敗 – 2011-03-03 15:17:21

1

在舊文檔中,您將找到關於使用dbi和dbi-odbc的信息,但這些都已過時。

技術的當前狀態,使用SQLSERVER適配器與TinyTds:

你會發現相關信息如何設置在這裏: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki

+0

我設法通過所有的步驟(的devkit,ODBC DSN ..)來獲得,但最終我還是得到的ActiveRecord :: ConnectionNotEstablished – 2011-03-03 17:14:01

3

首先,使用TinyTDS寶石及使用諮詢本頁面命名實例。 https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds

你應該能夠做到這一點:

development: 
    adapter: sqlserver 
    database: historicDB 
    dataserver: localhost\SQLEXPRESSS 
    username: dxt 
    password: dxt 
+0

我不明白,從維基。它讓我覺得如果我需要使用命名實例,我必須在freetds.conf文件中指定它。我當時正在努力尋找創造它的地方。這更有意義。很高興我找到了它。 – 2014-07-18 11:42:59

+0

我必須將'localhost:1433 \ SQLEXPRESS'作爲'port:'屬性不起作用 – 2017-02-10 22:51:47