I know I can create a connection string in the c# class itself, but I am trying to avoid doing that. I want to create the connection in the web.config, which I read is more secure. Nevertheless I couldn't find any example that has the following attributes specified:
- Host name
 - Port
 - SID
 - Username
 - Password
 - Connection Name
 
Could anyone help please with creating this in webconfig? I am connecting to oracle DB.
Oracle Developer Tools for Visual Studio is a tightly integrated "add-in" for Visual Studio. This tight integration makes it easy to create ASP.NET Web Applications that access Oracle database without requiring the developer write much code.
The tnsnames.ora file is a configuration file that defines connection parameters for your Oracle database instance. By default, tnsnames.ora resides in the following location: Solaris. Oracle_HOME/network/admin. Windows.
Here is the template:
     <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>
Here is one of mine - minus a real TNS name and username and password:
    <add name="MSOL" connectionString="Data Source={TNS_NAME};User ID={username};Password={password};pooling=true;min pool size=5;Max Pool Size=60" providerName="Oracle.DataAccess.Client"/>
                        After adding the connection string to the web.config you can use the following:
System.Configuration.ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString;
to retrieve the connection string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With