In order to connect oracle database from your asp.net application, you need to follow following steps.
2) Inside Web.Config File, Add connection string
<configuration>
<connectionStrings>
<add name="ConnStr"
connectionString="Data Source=<DB ServerName>;User ID=<SchemaName/UserName>;Password=<Password>;Persist Security Info=True;Connection Lifetime=10" providerName="System.Data.OracleClient"></add>
</configuration>
</connectionStrings>
Now you are ready to make oracle connection
Add following function in your code file.
3) Function to read oracle connection string from web.config file.
private OracleConnection GetConnection()
{
var conString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStr"];
string strConnString = conString.ConnectionString;
return new OracleConnection(strConnString);
}
4) Call GetConnection function to use oracle connection in your code.
//Sample code to open and close oracle connection
protected void Page_Load(object sender, EventArgs e)
{
OracleConnection oConn = GetConnection();
if (oConn != null)
{
oConn.Open();
oConn.Close();
}
}