原因:
ODTwithODAC112030安裝后,新裝了一個oracle11G客戶端,ODP.NET是通過 oracle11G客戶端連接服務名訪問的,
但在安裝后的"C:\app\furenjun\product\11.2.0\client_1\Network\Admin"文件夾中沒有對服務命名進行配置。
致Oracle.DataAccess.dll 不能解析oracle連接服務名。
解決方法:
將 原來裝的 C:\oracle\product\10.2.0\db_1\network\ADMIN 目錄下的 tnsnames.ora 文件 復制到
新裝的 C:\app\furenjun\product\11.2.0\client_1\Network\Admin 文件夾下即可。
oracle的官方解釋:
======================================================
http://www.oracle.com/technetwork/cn/topics/odt-faq-085407.html#ORA-12154:_TNS:could_not_resolve_the
ORA-12154: TNS:could not resolve the connect identifier specified
Scenario: You just installed Oracle Developer Tools, and now you cannot connect to the database using a Oracle connect alias that has worked in the past. You get a ORA-12154 error when you attempt to connect.
Cause: When you install Oracle Developer Tools, it typically creates a new "Oracle Home" (a new Oracle subdirectory, for example C:\oracle\product\10.2.0\my_new_home ) Each Oracle home maintains it's own copy of your connect aliases in a file called TNSNAMES.ORA. When you try to connect from this new Oracle home, none of your old connect aliases will exist in the new copy of TNSNAMES.ORA, therefore you get this error. They need to be copied over to the new Oracle home.
Solution: Copy <OLD_ORACLE_HOME>\NETWORK\ADMIN\TNSNAMES.ORA to <NEW_ORACLE_HOME>\NETWORK\ADMIN\TNSNAMES.ORA .
In some configurations, copying SQLNET.ORA and LDAP.ORA files from the same directory above may also be required.
Additionally: 64-bit Windows users who after doing the above steps still get ORA-12154 should either: 1) Upgrade to the latest version of their Oracle client that contains the fix for bug 3807408, or 2) rename subdirectories in their application that contain parenthesis to remove those parenthesis, in particular: C:\Program Files (x86)\Microsoft SQL Server and C:\Program Files(x86)\Microsoft Visual Studio 8
======================================================
我電腦上的開發環境:
======================================================
VS.NET 2010
Oracle 10G
ODP.Net ( ODTwithODAC112030.zip,下載地址:http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html)
ODAC 11.2 Release 5 (11.2.0.3.20) with Oracle Developer Tools for Visual Studio