C # design of Crystal Reports (basic ),

Source: Internet
Author: User

C # design of Crystal Reports (basic ),

Recently, I have worked as an intern in the company. Because the company needs to use a magic stuff called Crystal Report, the boss told us to learn. I am afraid that I will forget it later. I will record it for later reading convenience.

Tool used: vs2008

 

Basic Method 1,Use the push mode of the Crystal Report

Step 1. Right-click the current solution, choose "add"> "new", and select a dataset.

 

Step 2. Change the dataset name and select Add. For convenience, I did not change the name here. The following dataset design page is displayed.

 

Step 3: Click able in the toolbar on the left of the interface, and click the left button in the blank area on the right to obtain a table, which can be renamed.

 

Step 4: select the content of the dataset to be added. Right-click the table interface and add columns as follows. It can be added according to the actual situation. After a dataset is created, add a report.

 

Step 5. Right-click the current solution, choose "add"> "new", and select "CrystalReport2.rpt" as follows)

 

Click Add to confirm

 

Step 6. What is the problem? You can select the types of reports based on the actual situation. To facilitate the demonstration, select the following types. Click "OK ".

 

Step 7. As shown in the following figure, this is the data source selection page. Select the dataset we just created and select project data.

 

Step 8. Select the dataset we created and click "select". The right arrow in the figure is displayed.

 

Step 9. Select all information to be displayed in the report

 

There are no special requirements. Keep clicking Next until the last part.

 

Step 10. Click Finish. The following report is displayed, and the report is created.

 

Step 11: Go back to the form design interface, select the control in the toolbox, and drag it to the desired place.

 

Step 12: the control has a triangle. Click the expected button and select crystal Report.

 

Step 13. Select the crystal report we just created and confirm

 

Step 14. As shown in the following figure, our framework has been set up, and the next step is the data problem.

Step 15: add data: Add code similar to the following. The following is only the test data, mainly marked in red below, where the black is to add data for the dataset and add data according to the actual situation.

// Fill in dataset
DataSet1 ds1 = new DataSet1 ();
Ds1.test. AddmytableRow ("a1", "a2 ");
Ds1. test. AddmytableRow ("a1", "a2 ");
Ds1. test. AddmytableRow ("a1", "a2 ");
Ds1. test. AddmytableRow ("a1", "a2 ");
CrystalReport2 cr2 = new CrystalReport2 ();
Cr2SetDataSource (ds1 );
CrystalReportViewer1.ReportSource = cr2

The above is the processing of data in the push mode. If there is no error in the program, you can see the data you want. Haha.

2. Create a crystal report in PULL mode

Step 1. Select the crystal control in PULL mode If none of the above steps are required. in the upper-right corner, select new crystal Report. The following information is displayed, if we already have a data connection, select it directly. It is the same as the previous step. If there is no data connection, create a new data connection. Select the blue option in the selection,

 

Step 2. Select the connection mode and select the blue Option

 

Step 3. Connect to the service. The service is the connection string of the database. The user is the user that can operate the database in the database, and the password is the login password of the user. After filling in the information, click Next or complete.

 

Step 4: This step can be operated or not required. Add some connection attributes. If you have already completed the preceding settings, you do not need to enter them again.

 

Step 5. Click "finish". If all the items are filled in, the following information will be displayed. Are you familiar with this? continue to follow the previous steps for a long time, create your first crystal report.

 

It is a great pleasure to have built your first crystal report.

Note: The above method was implemented by myself after referring to the articles of many great gods on the Internet. I would like to thank you again.

Summary: I didn't know how to write a blog before. The most contact with a blog is to read a blog or read it. Today, I started my blog journey. I don't know how long it will last, but I will try my best. After reading everyone's attitude towards blogs, I also understand the truth that it is difficult to get something from others without knowing how to give it to others, maybe what I write is not the best, but as long as someone gets a little benefit from it, I will feel very happy. So I will try to stick to it. I also hope that you will be reading this article and write a blog together.

Before writing this article, I saw the two blogs I wrote. Some people still read them, which makes me more passionate. I started my internship at the company. I will work hard to become a qualified programmer as soon as possible. Well, how is it like I am writing an application for joining the party. Hahaha

Jaykb

Related Article

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.