oracle 使用ODP.Net的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6058744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problem on using ODP.Net
提问by Vano Maisuradze
I've successfully used Oracle Database 11g Release 2 (11.2.0.1.0)to connect oracle from .Net. (in reference Oracle.DataAccess.dll version was 2.112.1.0).
我已成功使用Oracle Database 11g 第 2 版 (11.2.0.1.0)从 .Net 连接 oracle。(参考 Oracle.DataAccess.dll 版本为 2.112.1.0)。
But when I installed ODP.NET and when I am trying to connect to oracle, it gives me an error: "ORA-12154: TNS:could not resolve the connect identifier specified".
但是当我安装 ODP.NET 并尝试连接到 oracle 时,它给了我一个错误:“ORA-12154:TNS:无法解析指定的连接标识符”。
How can I solve this problem?
我怎么解决这个问题?
Thanks!
谢谢!
回答by RonK
This usually occurs when your oracle client is not in the PATH of your computer.
这通常发生在您的 oracle 客户端不在您计算机的 PATH 中时。
Make sure that the PATH
environment variable contains both <Oracle client path>
and <Oracle client path>\bin
.
确保PATH
环境变量同时包含<Oracle client path>
和<Oracle client path>\bin
。
Also, this can happen if the SID
of the database you want to connect to is simply not defined in the tnsnames.ora
file under your oracle client installation path. If I recall correctly - it is under <Oracle client path>\network\admin\tnsnames.ora
此外,如果SID
您想要连接的数据库的 根本没有tnsnames.ora
在您的 oracle 客户端安装路径下的文件中定义,则会发生这种情况。如果我没记错的话 - 它在<Oracle client path>\network\admin\tnsnames.ora
Edit:The registry should contain an ORACLE entry set under: HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\
There should be a key named HOME0
with string values: ORACLE_HOMEand ID. I assume there are other values required as well - but those two I'm sure of. Check that ORACLE_HOMEpoints correctly to the oracle client location.
编辑:注册表应该包含一个 ORACLE 条目,设置在:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\
应该有一个HOME0
用字符串值命名的键:ORACLE_HOME和ID。我假设还需要其他值 - 但我确定这两个值。检查ORACLE_HOME是否正确指向 oracle 客户端位置。
回答by Christian Shay
Copy the TNSNAMES.ORA from the oracle home that works into the Oracle home that does not.
将 TNSNAMES.ORA 从工作的 Oracle 主目录复制到不工作的 Oracle 主目录。