Ufuk Can Bicici
Ufuk Can Bicici

Reputation: 3649

Weird exception thrown when connecting to Oracle from C#

I am trying to connect the Oracle database on my computer (localhost) from my C# code. I have the following simple code and connection string:

class AccessToOracleMigrator
{
    static void Main(string[] args)
    {
        string oradb = "Data Source=localhost:1521/XE User Id=MWBREP Password=MWBREP Integrated Security=no";

        OracleConnection conn = new OracleConnection(oradb);  // C#
        conn.Open();
        OracleCommand cmd = new OracleCommand();


    }
}

The code throws an exception when trying to run conn.Open(); line. The exception detail says: "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor". I think my connection string is missing some information but I could not find a meaningful explanation. What may be missing here?

Thanks in advance

Upvotes: 0

Views: 275

Answers (1)

S.L.
S.L.

Reputation: 1076

The ConnectionString ist not valid as i said.

Take a look to the following link to find out whats wrong:

OracleConnection.ConnectionString Property

Maybe you are just missing the ; between the connectionString properties

string oradb = "Data Source=localhost:1521/XE;User Id=MWBREP;Password=MWBREP;Integrated Security=no";

Upvotes: 2

Related Questions