參考:http://blog.csdn.net/tan_yixiu/article/details/6762357
操作系統:windows2008 Enterprise 64位
開發工具:VS2010
數據庫:oracle11g
安裝ODAC :ODTwithODAC112012后,出現ORA-12560:TNS:協議適配器錯誤
ODTwithODAC112012的下載地址:http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html
進入系統環境變量設置,查看Path路徑,發現在安裝ODAC時,同時安裝了oracle客戶端,
安裝完成后發現在Path路徑的最前面多了兩個安裝ODAC時產生的路徑
F:\app\Administrator\product\11.2.0\client_1;
F:\app\Administrator\product\11.2.0\client_1\bin;
此時path路徑為:F:\app\Administrator\product\11.2.0\client_1;F:\app\Administrator\product\11.2.0\client_1\bin;E:\app\Administrator\product\11.2.0\dbhome_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
這兩個路徑放到了oracle11g數據庫路徑前面,導致出現ORA-12560:TNS:協議適配器錯誤
將新加入的路徑F:\app\Administrator\product\11.2.0\client_1;F:\app\Administrator\product\11.2.0\client_1\bin;置后(oracle數據庫路徑的后面)即可解決ORA-12560:TNS:協議適配器錯誤。
例如:將path修改為:E:\app\Administrator\product\11.2.0\dbhome_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;F:\app\Administrator\product\11.2.0\client_1;F:\app\Administrator\product\11.2.0\client_1\bin;
解決ORA-12560:TNS:協議適配器錯誤。
接下來配置oracle客戶端,否則VS2010無法連接到oracle數據
先找到 Oracle 數據庫的安裝目錄,然后在其中找到如下目錄
例如:我的安裝在 E盤
E:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN
在其中找到下面標記的兩個文件:tnsnames.ora 和sqlnet.ora
然后將這兩個文件拷貝到 Oracle Developer Tools for Visual Studio .NET 的安裝目錄下的以下目錄,
例如:我的安裝在F盤
F:\app\Administrator\product\11.2.0\client_1\Network\Admin
然后便可以重啟機器了,就可以了(注意我這個oracle數據庫和Oracle Developer Tools for Visual Studio .NET 安裝在同一台服務器上了)。