Why invalid argument when connecting to an OracleDatabase ?

W

Wolfgang Meister

From a CSharp program I would like to connect to an OracleDatabase
with thefollowing code:

using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
....

string connectionstring = "User Id=peterm;Password=mypasswd;Data Source=XE;";
OracleConnection connection = new OracleConnection(connectionstring);
connection.Open();

In the Open() command I am getting an erro back:
ORA-12532 TNS invalid argument.

Why ?

I am absolute sure that I entered the correct login name and password.
So it must be either the Data Source argument or the syntax of the conntionstring.

I am using the Oracle Express version and the default database name is "XE".

So what else can be the error ?

When I define an ODBC Data Source TestOracle and connect with the following string:

string connectionstring = "User Id=peterm;Password=mypasswd;Data Source=TestOracle;";

I am getting an "ORA-12154 TNS connect could not resolved".
What's wrong with this ?

Wolfgang
 
A

Ashot Geodakov

First of all, can you connect to that database with any of Oracle tools (SQL
Plus, etc.)?

Your connection string seems right (at least we use the same syntax for it).
So, the question is whether of not

1) you have that "XE" thing registered in your tnsnames.ora and
2) you can connect to that database with SQL Plus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top