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

标签 c# c#-4.0 oracle10g

我是使用数据库的初学者。我正在尝试从 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/

相关文章:

c# - BackgroundWorker 和线程

c# - 如何防止输出参数以 WCF Web 服务中的返回参数结束?

c# - 从右到左写入txt文件

oracle - 禁用 Oracle 中所有作业的脚本(DBMS_JOB 包)?

java - "loader constraints violated when linking javax/xml/namespace/QName class"来自 Oracle 10g 上的 webapp

c# - 如何计算程序运行时间

c# - 委托(delegate)如何工作(在后台)?

c# - 在 DDD 的哪一层将类声明为聚合根?

c#-4.0 - Contract.Ensures 中的自定义方法

其他用户表的 Oracle 连接字符串