2012-02-24 79 views
0

因此,當試圖連接到DB2數據庫時,出現了「無效參數」的錯誤描述性錯誤消息。我可以使用連接字符串爲「jdbc:as400:// server; naming = system; errors = full; prompt = no」的JTopen JDBC驅動程序,使用SQUirrel(和JDBC)成功連接到它;IBM.Data.DB2.DB2Connection .open方法中的「無效參數」異常消息

由於jdbc連接工作,我知道它是一個Db2.net連接器問題。但錯誤消息「無效論據」阻礙了診斷從何處開始的任何努力。

string connStr = "server=server;uid=user;pwd=password"; 
using(DB2Connection conn=new DB2Connection(connStr)) 
{ 
    conn.Open(); 
    //System.ArgumentException: Invalid argument 
    // at IBM.Data.DB2.DB2ConnPool.ReplaceConnectionStringParms(DB2Connection connection, String szValue, DB2ConnSettings& pSettings, DB2ConnSettingsInternal& pSettingsInternal, Boolean bAttach) 
    // at IBM.Data.DB2.DB2Connection.set_ConnectionString(String value) 
    // at IBM.Data.DB2.DB2Connection..ctor(String connectionString) 
    // at AuroraDAL_ConnectionTests.DB2ConnectionTests.try1() in C:\Projects\...\DB2ConnectionTests.cs:line 31 
    // at AuroraDAL_ConnectionTests.DB2ConnectionTests.Execute() in C:\Projects\...\DB2ConnectionTests.cs:line 19 
    // at AuroraDAL_ConnectionTests.Program.Main(String[] args) in C:\Projects\...\Program.cs:line 20 
} 

使用DB2.net連接器程序文件目錄中的testconn20.exe,我試圖幾個選項,以上述第一連接串,然後,以改變所述速記鍵其普通寫法的值,(UID改變爲用戶ID,PWD改爲密碼等)

testconn20 server=server;database=database;user id=userid;password=password 

的這個結果返回相同的 「無效參數」 異常最終:

Step 1: Printing version info 
     .NET Framework version: 2.0.50727.5448 
     64-bit 
     DB2 .NET provider version: 9.0.0.2 
     Capability bits: ALLDEFINED 
     Build: 20090522 
     Factory for invairant name IBM.Data.DB2 verified 
     Elapsed: 0.089982 

Step 2: Connecting using "server=-------;database=------;userid=------;password=------" 
Invalid Argument Exception: 
     Connection string should be of the type 'Database=db2db; Server=mymachine:60000; User ID=db2user; Password=xxxxxxxx 


Test failed. 

有誰w^ith有些DB2和C#對我做錯了什麼有什麼建議?提前致謝。

回答

0

看來,IBM的網站不直接給你他們的.net數據連接器的最新和最大的位。通過徹底查找更新並找到他們的「Fix Central」,大部分問題得以解決。這是他們保持更新和修補程序的地方。然而,要獲得正確的包裝並不容易。

+0

這最終是正確的答案...加載的DLL有錯誤,修復了「Fix Pack 8」他們稱之爲。 – enorl76 2012-07-13 19:15:33

1

我沒有DB2的經驗,但在你的代碼,仔細尋找我注意到,你不指定數據庫=和端口號在服務器=您的連接字符串的

+1

是的,這是由於試圖混淆實際的服務器信息。我已經非常「容易」了。注意JDBC驅動程序如何在未指定數據庫的情況下工 此外,DB2是一個「特殊」服務器,似乎並不需要「數據庫說明符」。在這種情況下,一個數據庫是服務器(但我也是一個DB2新手,所以我有點懷疑) – enorl76 2012-02-24 16:55:08

相關問題