How to specify Oracle SID to connectionStrings in web.config?

1.1k Views Asked by At

I have an ASP.NET application whose connection to the database seems to fail to open because of the Oracle SID not being specified. I can't find any doc on how to specify it in the connection string. Did anyone have the same problem?

1

There are 1 best solutions below

0
On BEST ANSWER

Here is the sample :

         <connectionStrings>
            <add name="{ConnectionName}" 
            connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;" 
            providerName="Oracle.DataAccess.Client"/>
         </connectionStrings>

After adding the connection string to the web config you can use

System.Configuration.ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString;

To retrieve the connection string