2009年10月18日 星期日

[Database] .NET 連接 informix

一開始遇到問題,大概可以確定是 informix 版本的問題,但到底是 SDK版本太新太舊,還是引入參考的方式不對,一直沒頭緒……

卡了大半天,問有經驗的同仁才曉得,原來因為學校舊平台的校務系統也有裝一個 ifx sdk,造成環境變數中的 path會有兩個目錄設定,系統優先找第一個,自然讓開發的 AP無法順利編譯執行,顯示找不到正確的 dll -> 無法載入 DLL 'iclit09b.dll'
一個解決方案,是將原本預設的路徑砍掉,只留新的 path,本機執行就成功了。(但是這樣會使得校務系統無法順利執行,要能兼容兩種環境,恐怕就得動態切換或是隔離開發環境了。)

後來遇到第二個問題,是將程式由本機發佈到主機後發生的,這類似的問題,推敲了一天,才曉得我的本機 ifx 版本又跟 server 上的不同,所以無法順利執行。我想這又帶來一個很寶貴的經驗,開發環境跟發佈環境需要一致的重要 0rz~

ps. 這邊似乎也存在著一個 IIS的 bug:[節錄]
If you are trying to use IBM.Data.Informix (Client 2.81 TC3, 2.9, 3.5, etc.)
from IIS, and you still have this problem, I have a solution. I found that
IIS 5.1 has a bug!!. IIS cannot read the entire PATH environment variable if
it’s too long (my PATH has 1364 characters).

So if your informix dir is near the end of your PATH and your PATH is too
long, IIS will never read your informix dir ("C:\Program
Files\IBM\Informix\Client-SDK\bin"). Just put your informix dir at the
beginning of your PATH variable, and very important execute an "iisreset" and
the issue will gone away. I don't know if this bug remains in IIS 6.0 or later

沒有留言: