Summary of rdlc reports

Source: Internet
Author: User

The tangle of reports over the past two days has basically completed most of the functions. Summarize your recent learning achievements

First, the Microsoft rdlc report is made up of the following three parts: 1. create your own dateset set (the report dataset); 2. create your own report file. the rdlc file is used to draw report styles. It contains the export and print functions provided by Microsoft. In fact, it is not as flexible as generating a report to do less of these two functions. The aspx file on the front-end page of the report is basically inserted into a reportviewer and associated with the. rdlc File above. Do not forget to update the data source and insert scriptmanager.

I have done this in the past few days, but I have basically created these three files. I can find a lot of tutorials on the Internet to learn,

These are my main reference websites.

Http://www.cnblogs.com/JamesLi2015/archive/2010/01/30/1660086.html

Http://www.cnblogs.com/lauyee/archive/2010/07/26/1783694.html

Http://wenku.baidu.com/view/364f5048c850ad02de8041f5.html

Http://www.cnblogs.com/lauyee/archive/2010/07/18/1780124.html

Well, I started to do it. The previous steps are very simple: How to Make a dataset, how to draw your own rdlc, and how to check what is a dataset, what is a header, a row group, and a column ancestor. Parameters in the report can also be passed in. Use the localreport. setparameters () method.

The difficulty occurs when a dataset needs to be constructed dynamically. Many methods are provided at the beginning of the Internet, but they are always unsuccessful. Then, we will summarize the two points.

1. The referenced dataset name is incorrect. If your rdlc references the dataset dateset1, when the new dataset is automatically defined

Reportviewer1.localreport. CES. Add (new Microsoft. Reporting. webforms. reportdatasource ("dataset1", DS. Tables [0]);,

The name must be marked as dateset1, otherwise it cannot be recognized. The new dataset field must be the same as the original field name.

2. This is the most tragic one. It turned out that my SQL statement was wrong...

Let's look at the source code and the final running illustration.

Protected void button#click (Object sender, eventargs e) {// first reference the source report and modify the parameter reportparameter Rp = new reportparameter ("content", "warehouse"); this. reportviewer1.localreport. reportpath = appdomain. currentdomain. basedirectory + "report4.rdlc"; this. reportviewer1.localreport. setparameters (New reportparameter [] {RP}); string connstring = "Data Source = 192.168.1.111; initial catalog = samewayagile_4_14; integrated s Ecurity = true "; system. data. sqlclient. sqlconnection conn1 = new system. data. sqlclient. sqlconnection (connstring); system. data. sqlclient. sqlcommand command1 = new system. data. sqlclient. sqlcommand ("select goodsname as product name, abctypename as ABC class, middletypename as class, goodstypename as class, totalvalue as amount, actualquantity as quantity from part_goodsview", conn1); system. data. sqlclient. sqldataadapter ada1 = ne W system. data. sqlclient. sqldataadapter (command1); dataset DS = new dataset (); try {conn1.open (); ada1.fill (DS); DS. datasetname = "dataset1";} catch (exception ex) {string Ss = ex. message;} finally {conn1.close (); command1.dispose (); conn1.dispose ();} If (Ds. tables [0]! = NULL) {reportviewer1.localreport. datasources. clear (); reportviewer1.localreport. datasources. add (new Microsoft. reporting. webforms. reportdatasource ("dataset1", DS. tables [0]);} reportviewer1.localreport. refresh ();}

Today, I made an abnormal report. At first, I felt that it could not be implemented. Later I learned about the report file feature, which is the nested matrix in the matrix. Haha

Good illustration

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.