0

I'm beginner in oracle database ,want to write simple application to connect to the oracle database,write this code:

OracleConnection conn = new OracleConnection();
            conn.ConnectionString = @"Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = behbehzad)))";
            try
            {
                conn.Open();
                conn.Close();
                MessageBox.Show("Connect Successfull!!");
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());

            }


but when run the application get this error:
enter image description here


How can i solve that?thanks.

1
  • I presume that you gave the wrong parameters in your connectionstring. You can get help from connectionstrings.com how to write the correct connectionstring you need Commented Oct 28, 2015 at 8:50

2 Answers 2

1

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:

lsnrctl services <listener name>

  • Check that the SERVICE_NAME parameter in the connect descriptor of the net service name used specifies a service known by the listener.
  • If an easy connect naming connect identifier was used, check that the service name specified is a service known by the listener
  • Check for an event in the listener.log file
  • Check your Oracle PATH configuration on Windows
  • Change your connection string

And you can read this solution.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

conn.ConnectionString = @"localhost:1521/behbehzad";

No need to make it more complicated than it is.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.