behzad razzaqi
behzad razzaqi

Reputation: 1511

Why i get the connection string error when connect the oracle DB with c#?

I want to connect the oracle function and read any data from it,and i'm write this code for that purpose:

using (OracleConnection con = new OracleConnection("Data Source=WEBSERVICE_ACCESS;User Id=webservice_access;Password=xyz;"))
{
     con.Open();
     OracleCommand cmd = new OracleCommand("LOGIN");
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     //Add your parameters here
     cmd.Connection = con;
     OracleDataReader odr = cmd.ExecuteReader();
     while (odr.Read())
     {
          Console.WriteLine(odr.GetOracleValue(0));
     }
     Console.ReadLine();
 }

WEBSERVICE_ACCESS is my DATABASE NAME
webservice_access is my user name
but when run that code i get this error:

System.Data.OracleClient.OracleException: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor


What happened? How can I solve this?
enter image description here

Upvotes: 1

Views: 761

Answers (1)

staticvoidmain
staticvoidmain

Reputation: 793

The error ORA-12514 means that a listener received a request to establish a connection to a database or other service. The connect descriptor received by the listener specified a service name for a service (usually a database service) that either has not yet dynamically registered with the listener or has not been statically configured for the listener. This may be a temporary condition such as after the listener has started, but before the database instance has registered with the listener.

The possible resolutions for this error are

Check which services are currently known by the listener by executing: Hide Copy Code

lsnrctl services <listener name>

1) Check that the SERVICE_NAME parameter in the connect descriptor of the net service name used specifies a service known by the listener.

2) If an easy connect naming connect identifier was used, check that the service name specified is a service known by the listener.

3)Check for an event in the listener.log file

This answer on oracle forums should help you understand the difference between the SID and the SERVICE_NAME.

Upvotes: 2

Related Questions