Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: .Net OracleConnection Issue

Re: .Net OracleConnection Issue

From: Fred Exley <fexley221_at_msn.com>
Date: Sat, 4 Mar 2006 11:09:19 -0800
Message-ID: <120jpevp25a0iaf@corp.supernews.com>

"TRW" <timothy.williams_at_comverse.com> wrote in message news:1141403821.712723.239380_at_i39g2000cwa.googlegroups.com...
> Hello, I'm using the oracleclient namespace to attempt to connect to a
> Oracle 8 db on a server.
>
> I have the following code:
>
>
> try
> {
> string connectionString = "Data Source=ODS;User
> ID=xxx;Password=xxx";
> using (OracleConnection mdgDBconn = new
> OracleConnection(connectionString))
> {
> mdgDBconn.Open();
> Console.WriteLine("ServerVersion: " +
> mdgDBconn.ServerVersion
> + "\nDataSource: " + mdgDBconn.DataSource);
> }
> }
> catch (OracleException exc)
> {
> MessageBox.Show(exc.Message);
> }
>
>
> An exception is thrown saying
>
>
> ORA-125-05 TNS listener can not resolve SID given in the connect
> descriptor.
>
>
> I have the ODS in my tsnames.ora file shown:
>
>
> ODS =
> (DESCRIPTION =
> (ADDRESS_LIST =
> (ADDRESS = (PROTOCOL = TCP)(HOST = 10.207.249.2)(PORT = 1521))
> )
> (CONNECT_DATA =
> (SID = ODS)
> )
> )
>
>
> If I use the tnsping ODS command, I get a "OK" response
> Also, I use the tnsping <ip>, I get the "OK" response.
>
>
> If I change the connection string to use the IP address instead of the
> Service name, I get this exception.
>
>
> ORA-12514: TNS:listener could not resolve SERVICE_NAME given is connect
>
> descriptor.
>
> Any idea what is the problem? I must be missing something in my Oracle
>
> setup.

> thanks
>
> TRW

>

I suspect your host ip address may be the problem. But anyway, this works for me:

using Oracle.DataAccess.Client;
OracleConnection foodConnQ = new OracleConnection("Persist Security Info=True;User ID=monte;Password=zsdccc;Data Source=epicur;"); OracleDataAdapter ingr1DAq = new OracleDataAdapter("SELECT * FROM v2 where NDB_No = :NDB_No", foodConnQ); ingr1DAq.SelectCommand = new OracleCommand("SELECT * FROM v2 where NDB_No = :NDB_No", foodConnQ);



my local tnsnames file:
# tnsnames.ora Network Configuration File: C:\oracle\product\10.1.0\Client_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. EPICUR =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = monteamd)(PORT = 1521))     )
    (CONNECT_DATA =
      (SERVICE_NAME = epicur)
    )
  )

-Fred Received on Sat Mar 04 2006 - 13:09:19 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US