2. Use it in the code of the Development Environment
Create a winform project in C #, reference the com library of fastreport studio in the toolbar, select the plan control, and drag and drop it to the window.
Copy the frxdatatable to the program in the example program of the installation path of fastreport studio and add it to the program. The program code is as follows:
1 private void form1_load (Object sender, eventargs E)
2 {
3 tfrxreportclass report = new tfrxreportclass ();
4 // specify a template file for the report
5 Report. loadreportfromfile (application. startuppath + "\ demo. fr3 ");
6
7 // The class here is the name of the dataset used for timing in the report.
8 frxdatatable datatable = new frxdatatable ("class ");
9
10 // set Columns
11 datatable. Columns. Add ("ID", typeof (INT ));
12 datatable. Columns. Add ("name", typeof (string ));
13
14 string connstring = "Data Source = Master; persist Security info = true; user id = L; Pwd = 1; Unicode = true ";
15 oracleconnection conn = new oracleconnection (connstring );
16 oraclecommand command = new oraclecommand ("select T. ID, T. name from grade t", Conn );
17 try
18 {
19 conn. open ();
20
21 // assign a value
22 using (oracledatareader RDR = command. executereader ())
23 {
24 while (RDR. Read ())
25 {
26 datatable. Rows. Add (new object [] {RDR. getint32 (0), RDR. getstring (1 )});
27}
28 datatable. acceptchanges ();
29}
30}
31 finally
32 {
33 conn. Close ();
34}
35 // bind
36 datatable. assigntoreport (true, report );
37 datatable. assigntodataband ("masterdata1", Report );
38
39 This. axtfrxpreviewx1.report = report;
40 Report. showreport ();
41}
42
Running Program display result: