Detailed description of ASP. NET rdlc report development

Source: Internet
Author: User

I did not upload images. Now I have reorganized it. I have a picture, which is more detailed.

 

Rdlc report development

Open Visual Studio 2005

Create an ASP. NET Website

Add Dataset

The dataset Configuration window tableadapter is automatically called up.

If the window above is not automatically called up, you can

You can call up the tableadapter window above.

New Database Connection

The following step saves the database connection to the config file.

In the following step, you can select the SQL generation method.

Let's go back to SQL Server Query analyzer first

Enable SQL Server Query Analyzer

Create a stored procedure, for example

Then return to Visual Studio 2005

Select the current stored procedure and click Next.

Here, we only need to select the required stored procedure, such as the created employeereport.

Click Finish. Complete the configuration of the tableadapter wizard.

Add Report item

Drag a table to the report designer.

Select a field in the website dataset and drag it to the column in the table.

Create An ASPX page and drag a report viewer control to the page.

In the reportviewer task window, select the rdlc file you just created

Generate a solution and then execute

The report is executed successfully.

Now the report has been developed successfully.

Note:

1. the SQL script

Create proc employeereport

As

Select * from employee

Go

In actual report development, do not use select *. Only the fields to be viewed in the report are reported.

2. Sometimes, you may need to select some conditions to view the report selectively. Instead of binding all data

For example, you may only need to view data between and

The procedure is as follows:

Create An ASPX page, and write the following in the View Report event:Program

Reportviewer1.localreport. reportpath = appdomain. currentdomain. basedirectory + "/report/request. rdlc ";

Datetime dtfrom = convert. todatetime (txtdatefrom. Text );

Datetime dtto = convert. todatetime (txtdateto. Text );

String requester = txtrequester. text;

String dept = txtrequestdept. text;

String material = ddlmaterial. selectedvalue;

String iprstatus = ddlstatus. selectedvalue;

Datatable reqrpt = reportdb. requestreport (dtfrom, dtto, material, DEPT, requester, iprstatus );

If (reqrpt! = NULL)

{

Reportviewer1.localreport. CES. Clear ();

Reportviewer1.localreport. CES. Add (

New Microsoft. Reporting. webforms. reportdatasource ("request_requestreport", reqrpt ));

Reportviewer1.localreport. Refresh ();

}

Reportviewer1.localreport. Refresh ();

Upload the data value to the SQL statement based on the selected parameters. The following is the source code of the requestreport method.

Datatable requestreport (datetime dtfrom, datetime dtto, string pmaterial, string pdept, string prequester, string piprstatus ){

String MySQL = purchase;

String whdate = "requestdate between' {0} 'and' {1 }'";

MySQL = MySQL + String. Format (whdate, dtfrom, dtto );

String whmaterial = "and materialcode = '{0 }'";

If (pmaterial! = "All ")

{

MySQL = MySQL + String. Format (whmaterial, pmaterial );

}

String whdept = "and requestdepartment = '{0 }'";

MySQL = MySQL + String. Format (whdept, pdept );

String whrequester = "and requester = '{0 }'";

If (prequester! = "All ")

MySQL = MySQL + String. Format (whrequester, prequester );

String whiprstatus = "and iprstatus = {0 }";

If (piprstatus! = "All ")

{

MySQL = MySQL + String. Format (whiprstatus, piprstatus );

}

Idataprovider privider = dataprovider. createdataprovider ();

Dataset DS = privider. retrivedataset (MySQL );

If (Ds! = NULL & Ds. Tables. Count> 0)

Return Ds. Tables [0];

Else

Return NULL;

}

Const string Purchase = "select serialno, ledgeracc, costcenter, requester," +

"Requestdate, requestdepartment, materialcode," +

"Brand, specifications, unit, quantity, usage," +

"Expecteddeliverydate, currency" +

", Quotation1supplier, quotation1unitprice, quotation1amount," +

"Quotation2supplier, quotation2unitprice, quotation2amount," +

"Quotation3supplier, quotation3unitprice, quotation3amount," +

"Proposedquotationsupplier, proposedquotationunitprice," +

"Proposedquotationamount, quotationremarks, iprstatus, qtyto, unitpriceto from IPR where ";

3. When designing a report, you can use the preceding method. during actual running, you can replace it with an SQL statement and upload it to reportdatasource, as long as a considerable table structure field exists.

4. The definition of a report is structured in XML format. If you are familiar with the definition format specification of a report, you can open it in a text editor and directly modify it.

5. if SQL Server 2005 is used as a server report, it may be further convenient for design and development. here we use.. NET Framework components, the client only needs to install. net framework2.0. No additional components are required.

 

The original connection is as follows:

Rdlc report development

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.