TNS:无法解析 .NET OracleClient 中指定的连接标识符

发布于 2024-12-27 15:28:19 字数 969 浏览 2 评论 0原文

我在我的机器上使用 .net OracleClient 连接到 Oracle 中的数据库。当我尝试连接时,它显示此 TNS 错误。

现在,我已经编辑了 tnsnames.ora 文件和 sqlnet.ora 文件。 当我使用 ServerExplorer 访问 Oracle 时。它连接到 Oracle 数据库并获取所有内容。

我确实有一个来自 Oracle 网站本身的 ODAC 组件,我也尝试过,但没有成功。

我的连接字符串是 <添加名称=“ConnectionString”connectionString=“数据源=ff.WORLD;密码=vlc;用户ID=vlc” providerName="Oracle.DataAccess.Client" />

我在这两个组件中尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

月牙弯弯 2025-01-03 15:28:19

现在它为我工作。
我们执行此操作所遵循的步骤。

  • 我们注意到我们有多个 TNSNames.ORA 文件。
  • 然后我们可以发现它指向Oracle Client版本8.x。所以它是
    无法正常工作。因此,为了使用它...
  • 我们删除了所有 ORacle 客户端版本(因为我们无法
    将 VisualStudio Oracle 客户端指向更新版本)

  • 再次重新安装。重新启动后,它开始工作。

Now Its working for me.
The steps we followed for doing this.

  • We noticed we were having more than One TNSNames.ORA file.
  • Then we could find it was pointing to Oracle Client version 8.x.So it was
    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.

十秒萌定你 2025-01-03 15:28:19

我们让 ODAC 与此连接字符串以及定义数据源 - PROD 的 tnsnames.ora 一起正常工作,

<ConnectionString name="ServerConnection">Data Source=PROD;User Id=DBUSER1;Password=DBPASSWORD1;Pooling=False;</ConnectionString>

与 Oracle/Network/Admin 文件夹中的示例 tnsnames.ora 文件中的相同。

tnsnames.ora 条目如下所示

DDSENT3 =    
  (DESCRIPTION =        
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.10)(PORT = 1521))    
    (CONNECT_DATA =    
      (SERVER = DEDICATED)    
      (SERVICE_NAME = DDSENT3)    
    )
  )

We have ODAC working fine with this connection string,

<ConnectionString name="ServerConnection">Data Source=PROD;User Id=DBUSER1;Password=DBPASSWORD1;Pooling=False;</ConnectionString>

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

DDSENT3 =    
  (DESCRIPTION =        
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.10)(PORT = 1521))    
    (CONNECT_DATA =    
      (SERVER = DEDICATED)    
      (SERVICE_NAME = DDSENT3)    
    )
  )
灵芸 2025-01-03 15:28:19

尝试将以下内容添加到您的 web.config 中:

<oracle.manageddataaccess.client>
    <version number="*">
      <settings>
        <!-- Set this path if you are using TNS aliases as connection strings (not recommended) -->
        <!-- Instead you can use "SERVER_NAME:PORT/SERVICE_NAME" as your data source -->
        <setting name="TNS_ADMIN" value="C:\oracle\product\11.2.0\client_3\Network\Admin\"/>
      </settings>
...

当然,只需添加您的文件夹位置即可。

Try adding the following to your web.config:

<oracle.manageddataaccess.client>
    <version number="*">
      <settings>
        <!-- Set this path if you are using TNS aliases as connection strings (not recommended) -->
        <!-- Instead you can use "SERVER_NAME:PORT/SERVICE_NAME" as your data source -->
        <setting name="TNS_ADMIN" value="C:\oracle\product\11.2.0\client_3\Network\Admin\"/>
      </settings>
...

Just add your folder location, of course.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文