c# - 从 C# 连接到 Oracle

标签 c# oracle

我正在尝试从 C# 连接 Oracle 11g。我已经关注了 [this link],像这样定义了连接别名:

moviess =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = xe)
    )
  )

尝试在 Visual Studio 中使用服务器资源管理器进行连接时,出现以下错误: enter image description here

这里是 Oracle Developer Tool for Visual Studio 的安装目录。 enter image description here

我哪里错了?请帮助我。

最佳答案

问题是:

ORA-12154: TNS: 无法解析指定的连接标识符

这是原因:

https://docs.oracle.com/cd/B19306_01/server.102/b14219/net12150.htm

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

Cause: A connection to a database or other service was requested using a connect identifier, and the connect identifier specified could not be resolved into a connect descriptor using one of the naming methods configured.

For example, if the type of connect identifier used was a net service name then the net service name could not be found in a naming method repository, or the repository could not be located or reached.

Action:

- If you are using local naming (TNSNAMES.ORA file):

- Make sure that "TNSNAMES" is listed as one of the values of the NAMES.DIRECTORY_PATH parameter in the Oracle Net profile (SQLNET.ORA)

- Verify that a TNSNAMES.ORA file exists and is in the proper directory and is accessible.

- Check that the net service name used as the connect identifier exists in the TNSNAMES.ORA file.

问:Oracle 11g 是否真的安装在您的本地 PC 上?如果不是,则不能使用“localhost”。您还必须安装 Oracle 客户端。

相关链接:

关于c# - 从 C# 连接到 Oracle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31641951/

相关文章:

c# - Insert 的 MySQL C# 性能

C# <--> VB.NET DLL 转换

sql - 最好的 Oracle SQL 查询分析工具

java - jdbcexecuteBatch 与使用大查询执行

oracle - 使用 docker : "TNS:listener: all appropriate instances are blocking new connections" error 启动 oracle

使用 Azure Devops Pipeline 部署 Oracle 对象

node.js - 测试从 nodejs 应用程序到 Oracle DB 的连接

c# - 通过属性设置 Treeview HierarchicalDataTemplate

c# - WinForm 中的 DataGridView 自定义排序

c# - 从 ClickOnce 应用程序以普通用户身份启动进程