VS2008连接oracle"oracle ora-12504:tns 监听程序在connect_data中未获得service _name"

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VS2008连接oracle"oracle ora-12504:tns 监听程序在connect_data中未获得service _name"相关的知识,希望对你有一定的参考价值。

tnsnames.ora 文件
# Generated by Oracle configuration tools.

ZS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = zs)
)
)

ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)

KCIS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.252)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = KCIS)
)
)

listener.ora

# listener.ora Network Configuration File: d:\app\administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = d:\app\administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:d:\app\administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = d:\app\administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:d:\app\administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT = 1521))
)
)

ADR_BASE_LISTENER = d:\app\administrator

参考技术A net manager重新为你的数据库配个listner吧。

像我的listner的格式为:

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 7NQARM2O3BV7R51)(PORT = 1521))
)
)
ipc协议是不是你所需要的?7NQARM2O3BV7R51为我的计算机名,我怀疑你的listner中host用的IP需要联网情况下才能解析(而你此时仅为单机测评,无网络环境),试着把它改为计算机名解析或设为127.0.0.1;
参考技术B 两个文件的SID和servername对不上 参考技术C net manager 设置 图形化方便

ado.net如何连接 oracle?

VS 2010 oracle11g
关键是connectionstring 的值是多少?
我连接不上啊

OracleConnection conn = new OracleConnection("DataSource=xxxxxxx;UserId=xxxxxx;Password=xxxxxxxx;");
conn.Open();
string sql = "........";
OracleCommand cmd = new OracleCommand(sql, conn);
conn.Close();
步骤就是:1.建立Oracle的连接conn,里面包含了数据库地址,用户名和密码。并打开连接
2.确定你的SQL查询语句,写在sql字符串里
3.声明OracleCommand执行变量 cmd,包含了SQL语句和连接变量conn
4. 关闭连接
连接字符串根据自己的实际情况设置
参考技术A OracleConnection conn = new OracleConnection( "Data Source=数据库名称;user=用户名;password=密码;");
conn.Open();
数据操作;
conn.Close();
参考技术B 你用的软件还都挺先进的啊

以上是关于VS2008连接oracle"oracle ora-12504:tns 监听程序在connect_data中未获得service _name"的主要内容,如果未能解决你的问题,请参考以下文章

我用vs2005连接oracle数据库,提示我说ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME

ado.net如何连接 oracle?

sql2008如何连接操作oracle

VS2015连接Oracle数据库(转)

在.net中使用OracleConnection类提示过时,请问针对oracle数据库的连接有其他新类替代吗?

如何实现SQLServer2008R2连接Oracle11gR2