gpt4 book ai didi

c# - 将 C# 应用程序与 Oracle 10g 连接 : ORA-12154: TNS:could not resolve the connect identifier specified

转载 作者:行者123 更新时间:2023-11-30 15:02:46 25 4
gpt4 key购买 nike

我是使用数据库的初学者。我正在尝试从 C# 应用程序访问 Oracle10g 数据库。但是当我这样做时,我得到了这个错误:

ORA-12154: TNS:could not resolve the connect identifier specified"

我正在使用以下代码:

string oradb = "Data Source=ORCL;User Id=system;Password=goodbye;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();

连接字符串oradb是否有错误?

最佳答案

启动 Visual Studio,打开 View 菜单 + Server Explorer。

  1. 鼠标右键单击数据连接 + 添加连接 + 选择Oracle 数据库
  2. 服务器名称:localhost您机器的名称,设置用户名和密码,然后单击“测试连接”以验证上述参数。如果测试成功,请按 OK。

从属性窗口中你可以获得连接字符串,它看起来应该是这样的:

Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True

关于c# - 将 C# 应用程序与 Oracle 10g 连接 : ORA-12154: TNS:could not resolve the connect identifier specified,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12445201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com