我正在尝试从 C# 连接 Oracle 11g。我已经关注了 [this link],像这样定义了连接别名:
moviess =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xe)
)
)
尝试在 Visual Studio 中使用服务器资源管理器进行连接时,出现以下错误:
这里是 Oracle Developer Tool for Visual Studio 的安装目录。
我哪里错了?请帮助我。
最佳答案
问题是:
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/