Asp. NET report Simple use example __.net

Source: Internet
Author: User

In the ASP.net application, we sometimes need to display some data as a statistical graph in the page, and the ASP.net report provides this convenience. As shown in the following figure, it is a daily number of visits to the site IP, PV statistics map:



Let's take a look at how to do it.

First, test environment

Visual Studio 2008 + SQL Server 2005

Second, the realization step

1. Data preparation

In SQL Server 2005, execute the bottom SQL, and the data is ready to complete:
Copy content to Clipboard program code--create table
CREATE TABLE LOGTB
(
Id int Identity (1,1) primary key,
Ipcount int,
Pvcount int,
Logdate datetime
)
--insert into
Insert into LOGTB (ipcount,pvcount,logdate)
Select 10,25, ' 2010-06-25 ' UNION ALL
Select 20,50, ' 2010-06-26 ' UNION ALL
Select 30,75, ' 2010-06-27 ' UNION ALL
Select 40,100, ' 2010-06-28 ' UNION ALL
Select 50,125, ' 2010-06-29 ' UNION ALL
Select 30,150, ' 2010-06-30 '
2. Set up data sets

Create a new site with Visual Studio 2008, and then add a connection in Server Explorer for the library that contains the table that you established in step 1th:





Next, add a DataSet (XSD) file to the site:



Then drag the LOGTB table from Server Explorer onto the DataSet page, and the dataset is set up:



3. Adding reports and associating with datasets

To add a report file to a site:



From the Toolbox → report items, pull a chart to the report interface:



From the site data source, drag fields to the chart, add data fields and category fields to the chart, as shown in the following illustration:



Right-click on the chart, open the Properties page, you can do a little more landscaping, such as changing the chart type, add X,y axis title, and so on:



At this point, the report file is ready to complete.

4. Display the report on the ASP.net page

Add a asp.net page to the site, and then pull a microsoftreportviewer control onto the page from the Toolbox → report:



Select a report for the Microsoftreportviewer control:



Then set the Microsoftreportviewer control slightly:

Copy content to Clipboard program code Asyncrendering=false
Showtoolbar=false
Sizetoreportcontent=true
OK, all steps complete, preview the next page:


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.