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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:43:21  来源:igfitidea点击:

Problem on using ODP.Net

c#.netoracleodp.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 PATHenvironment 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 SIDof the database you want to connect to is simply not defined in the tnsnames.orafile 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 HOME0with 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_HOMEID。我假设还需要其他值 - 但我确定这两个值。检查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 主目录。

http://www.oracle.com/technetwork/topics/dotnet/odt-faq-085407.html#ORA-12154:_TNS:could_not_resolve_the

http://www.oracle.com/technetwork/topics/dotnet/odt-faq-085407.html#ORA-12154:_TNS:could_not_resolve_the