What do I have to write in OracleConnection string for "Data Source" ?

W

Werner Sammer

I tried to connect to an existing Oracle Database with the following ConnectionString:

using System.Data.OracleClient; // + Added Reference "System.Data.OracleClient"

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

This code yields an "Invalid argument" ORA-12532 error.

Why ?

Even when I switch to

using Oracle.DataAccess.Client; // + Added Reference "Oracle.DataAccess"

I got the same error.

"XE" is the name of the Oracle Express Database.

What else can I do ?
Does the sequence of Data Source, User Id and Password in the connection string matter ?

Do I have to declare the "Data Source" somewhere else (beside the Reference)?

Werner
 
J

James Irvine

Werner said:
I tried to connect to an existing Oracle Database with the following ConnectionString:

using System.Data.OracleClient; // + Added Reference "System.Data.OracleClient"

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

This code yields an "Invalid argument" ORA-12532 error.

Why ?

Even when I switch to

using Oracle.DataAccess.Client; // + Added Reference "Oracle.DataAccess"

I got the same error.

"XE" is the name of the Oracle Express Database.

What else can I do ?
Does the sequence of Data Source, User Id and Password in the connection string matter ?

Do I have to declare the "Data Source" somewhere else (beside the Reference)?

Werner


1. in web.config:

<connectionStrings>
<add name="jamieOracle" connectionString="user
id=jamie;password=jamie;data
source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jamieamd)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=jamie)))"/>
</connectionStrings>



2. in your app:

// create an Oracle data provider connection:
string connStr =
ConfigurationManager.ConnectionStrings["jamieOracle"].ConnectionString;
OracleConnection con = new OracleConnection(connStr);
 

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