Binding of Oracle Database to ActiveReport

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

ActiveReport and multiple sources of data interaction, including OLEDB, SQL, XML and set object.
In this paper we will describe how to bind the Oracle to the ActiveReport database .
This is a very easy thing. Below we distribution binding method:
1.    Use VS to create ActiveReport7 (Code-Based) project.
2.    Add Oracle.DataAccess.dll reference.
3.    Add the Oracle.DataAccess namespace.
4.    Add the following code in the Report Start event:
A. set the database connection string
The B. configuration data query
C. through the Data Adapter to retrieve data, filling DataTable
D. Data Source property DataTable
E. closes the database connection string
The following code:

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 Id=hr;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(); }

5.    Now, add display data controls in the report, to set the control the DataField attribute for the fields in the DataTable name.
6.    The binding results through the report designer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Vanessa at November 22, 2013 - 10:44 AM