TNS:无法解析 .NET OracleClient 中指定的连接标识符
我在我的机器上使用 .net OracleClient 连接到 Oracle 中的数据库。当我尝试连接时,它显示此 TNS 错误。
现在,我已经编辑了 tnsnames.ora 文件和 sqlnet.ora 文件。 当我使用 ServerExplorer 访问 Oracle 时。它连接到 Oracle 数据库并获取所有内容。
我确实有一个来自 Oracle 网站本身的 ODAC 组件,我也尝试过,但没有成功。
我的连接字符串是
我在这两个组件中尝试使用 ServerExplorer。它与服务器资源管理器配合得很好,我也得到了数据。 但是当我编写代码时,它抛出了这个错误 ORA-12154: TNS:无法解析指定的连接标识符
这是我尝试连接的代码。
OracleConnection con = new OracleConnection(WebConfigurationManager.ConnectionStrings["netOracleClient"].ConnectionString);
告诉我解决这个问题的方法吗???
注意:我们这里有机器,我们可以使用 OracleClient for .net 通过相同的 TNS 访问相同的数据库。我也想使用相同的..
请帮助我。
Im using a .net OracleClient in my machine for connecting to a Database in Oracle. When im trying to connect its showing this TNS Error.
Now, I have edited the tnsnames.ora file and sqlnet.ora file.
When I access the Oracle using a ServerExplorer. It gets connected to the Oracle Database and its fetching everything.
I do have a ODAC component from oracle website itself which also, i tried but dint worked.
My connection string is<add name="netOracleClient" connectionString="Data Source=ff.WORLD;Persist Security Info=True;User ID=vlc;Password=vlc;Unicode=True"
providerName="System.Data.OracleClient" />
<add name="ConnectionString" connectionString="DATA SOURCE=ff.WORLD;PASSWORD=vlc;USER ID=vlc"
providerName="Oracle.DataAccess.Client" />
I tried with ServerExplorer in both the components. Its working FINE with Server explorer and im getting the datas too.
But when i write the code its throwing me this error ORA-12154:
TNS:could not resolve the connect identifier specified
This is the code from which Im trying to connect.
OracleConnection con = new OracleConnection(WebConfigurationManager.ConnectionStrings["netOracleClient"].ConnectionString);
Tell me a way to resolve this???
NOTE: We have machines here itself from which we are accesing the same database with the same TNS using OracleClient for .net. I also wants to use the same..
Please Help me in this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
现在它为我工作。
我们执行此操作所遵循的步骤。
无法正常工作。因此,为了使用它...
我们删除了所有 ORacle 客户端版本(因为我们无法
将 VisualStudio Oracle 客户端指向更新版本)
再次重新安装。重新启动后,它开始工作。
Now Its working for me.
The steps we followed for doing this.
not working properly. So for working with it...
We removed all the ORacle Client Versions(since we were not able
to point VisualStudio Oracle Client to a newer version)
Re-Installed it again. After a Restart it started Working.
我们让 ODAC 与此连接字符串以及定义数据源 - PROD 的 tnsnames.ora 一起正常工作,
与 Oracle/Network/Admin 文件夹中的示例 tnsnames.ora 文件中的相同。
tnsnames.ora 条目如下所示
We have ODAC working fine with this connection string,
together with the tnsnames.ora defining the Data Source - PROD same like in the sample tnsnames.ora file in the Oracle/Network/Admin folder.
tnsnames.ora entry goes like this
尝试将以下内容添加到您的
web.config
中:当然,只需添加您的文件夹位置即可。
Try adding the following to your
web.config
:Just add your folder location, of course.