Use fastreport studio to develop reports (2)

Source: Internet
Author: User
Tags oracleconnection
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.