Oracle happens to be a widely used datasource and let’s see how we can bind Section Reports to this database. So before we get started let’s get the ingredients in place that we would need for connecting to an Oracle datasource. The only thing that we would need is an Oracle Data Provider for .NET which would allow us to take advantage of Oracle database functionality and expose us the API that we would need to work with Oracle inside a .NET application. We have used the one that is provided by Oracle i.e. the ODP.NET library (Oracle.DataAccess.Client assembly). This library can be downloaded from here. Now that we have the ingredients in place, let’s go ahead and create an application that uses Oracle as a datasource for the a Section Report.
private OracleConnection con;
private OracleCommand cmd;
private OracleDataAdapter adap;
DataTable dt = new DataTable();
private void rptOracle_ReportStart(object sender, EventArgs e)
{
string oraDB = "Data Source=XE;User;Password=hr;";
con = new OracleConnection(oraDB);
con.Open();
cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = "select * from DEPARTMENTS";
cmd.CommandType = CommandType.Text;
adap = new OracleDataAdapter(cmd);
adap.Fill(dt);
this.DataSource = dt;
con.Close();
}
~~~