I'm trying to connect my local Oracle 11g database using server explorer in Visual Studio 2010. I tried to setup everything as per instruction, but I'm still getting an ORA-12504 error.
Here is the error:
Here is my tnsnames.ora contents:
# tnsnames.ora Network Configuration File: C:\app\rsahi\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
VENUS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SPRPRG020)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = VENUS)
)
)
LISTENER_VENUS =
(ADDRESS = (PROTOCOL = TCP)开发者_运维知识库(HOST = SPRPRG020)(PORT = 1521))
listener.ora file contents,
# listener.ora Network Configuration File: C:\app\rsahi\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = SPRPRG020)(PORT = 1521))
)
)
ADR_BASE_LISTENER = C:\app\rsahi
Try this, in Visual Studio's Server Explorer Data Connection panel:
Data source name: SPRPRG020/VENUS
i.e. the Data source name format is SERVER_NAME_OR_IP/DATABASE_NAME
In the "Connection Properties" -> "Advanced" set in the "Data Source" field the information in format HOST/SERVICE_NAME. E.g. 127.0.0.1/TEST
Without having much knowledge in connecting ODP.NET with an Oracle DB, I suggest you start using SERVICE_NAME (e.g: VENUS) in your connection parameters.
Oracle states that:
From 11g onwards, the feature of using the hostname provided in the /etc/hosts file, as the alias / service name has been changed. As a result, the user will have to provide the service name while connecting OR configure the target listener with a default service name.
One way to bypass the SERVICE_NAME client side requirement is to force the Listener always sending you on the same SERVICE by telling it to do so in the tnsnames.ora
DEFAULT_SERVICE_LISTENER = VENUS
But I do not suggest you do that as it's quite restricting.
I have experienced the same problem when I was trying to create LinkedServer with Oracle 11g. My oracle instance name was: PC-2.my.xgen and my listener name was "NB". The last parameter of first statement is actually the concatenation of Oracle server instance and listener name.
So I have write down the following statements in SQL server.
--add a linked server into SQL server
--last parameter contains OracleInstance / Listener Name of desired database
EXEC sp_addlinkedserver 'OracleLinkedServer4', 'Oracle', 'MSDAORA', 'PC-2.my.xgen/nb'
--add login information into linked server
EXEC sp_addlinkedsrvlogin 'OracleLinkedServer4', false, Null, 'system', '123456'
In Oracle database "NB" I have a table named : CRD_CIL_NOTIFICATION_TYPE. So I have written down the following statement to get the records.
select * from OracleLinkedServer4..SYSTEM.CRD_CIL_NOTIFICATION_TYPE
In the "Connection Properties" -> "Advanced" set in the "Data Source" field the information in format HOST:PORT/SERVICE_NAME. E.g. 10.xxx.xxx.xxx:1521/SIDNAME
精彩评论