3

I have below connection string in my Web.config:

<add name="OracleString" providerName="System.Data.OracleClient" ConnectionString ="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;"/>

when I try to retrieve the same using below code

ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["OracleString"];

DbProviderFactory factory = DbProviderFactories.GetFactory(connectionStringSettings.ProviderName);

DbConnection conn = factory.CreateConnection();
//set the connection string
conn.ConnectionString = connectionStringSettings.ConnectionString;

its throwing exception:

Keyword :description is not supported

Code's
  • 208
  • 2
  • 18
  • my mistake I have not copied the connectionString attribute- while posting the question .....but that is not the case – Code's Aug 10 '15 at 14:13
  • The Microsoft version of the Oracle client has been deprecated for some time now. The ODP.Net client from Oracle is now preferred (referenced in Marcos Lommez's answer). – Mark W Aug 10 '15 at 16:30

3 Answers3

0

Patterns and Standarts are a great think.

Try to change your connection string for something like the indicated in Microsoft's Documentation and I am sure that it will work

In your case I think this will do the trick:

<add name="OracleString"
  connectionString="Server=tcp:MyHost,MyPort;Database=MyOracleSID;UserID=myUsername;Password=myPassword"
  providerName="System.Data.OracleClient" />

Edit: After some research I found out that the type of connection you are using is possible for oracle, but I believe you forgot Data Source or Server before your Description, something like this should do the trick

<add name="OracleString" providerName="System.Data.OracleClient" ConnectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;"/>

Resource

Community
  • 1
  • 1
Diogo Cunha
  • 1,194
  • 11
  • 23
0

Coder2014, some days ago I´ve a problem with my web.Config. When pasting the connectionString to the web.config, the string was using a different enconding. To verify that, i used the http://www.xmlvalidation.com/ to validate the file.

If is not your case, maybe you should use the tnsnames.ora. Take a look at https://www.connectionstrings.com/oracle-data-provider-for-net-odp-net/

Marcos Lommez
  • 126
  • 10
0

Based on similar posts for the error message format

Keyword ______ is not supported

The problem seems to lie in the engine not recognizing what "Description" is (at the beginning of your connection string).

I do not think your connection string should like that. You copied and pasted what you had in your TNSnames.ora.

An example of a oracle connection string is:

<add name="oracleConnectionString"
     connectionString="Server=yourDBServer; User ID=userIdToConnectWith; Password=userIdPassword; Unicode=True"
     providerName="System.Data.OracleClient" />

From your sample above, I am not sure - but I think "MyOracleSID" would go in place of "yourDBServer".

Veverke
  • 9,208
  • 4
  • 51
  • 95
  • when I used above approach - am getting Exception - ORA-12541: TNS:no listener – Code's Aug 10 '15 at 22:39
  • are you able to connect to this database in any other way ? Sql Plus ? Toad / PL/SQL Developer ? – Veverke Aug 11 '15 at 08:07
  • I am able to connect to sql developer – Code's Aug 11 '15 at 09:54
  • You have an oracle database you are trying to connect to. Do you succeed in connecting to it in any way? Do you know its server name ? – Veverke Aug 11 '15 at 10:04
  • If so, what is the name of the Oracle DB you connect to, whenever you successfully do so ? You need to use that very same name in the connection string at `Server=______`. If you succeed connecting to it via a GUI program, than the server should be up and receiving ORA-12541 does not make sense – Veverke Aug 11 '15 at 11:53