Home arrow C# arrow Page 4 - Creating Graphical Reports With Crystal Reports in .NET
C#

Creating Graphical Reports With Crystal Reports in .NET


In this article Farhan Zia investigates some of the power that Microsoft .NET provides to accomplish converting business data into reports using Crystal Reports.

Author Info:
By: Wrox Team
Rating: 4 stars4 stars4 stars4 stars4 stars / 202
November 10, 2002
TABLE OF CONTENTS:
  1. · Creating Graphical Reports With Crystal Reports in .NET
  2. · The Database
  3. · Creating Web Pages
  4. · The Report
  5. · Creating Report Parameters
  6. · Passing Parameters to a Report
  7. · Conclusion

print this article
SEARCH DEVARTICLES

Creating Graphical Reports With Crystal Reports in .NET - The Report
(Page 4 of 7 )

We will create our report using Visual Studio .NET and will save it in a .rpt file. The code above is actually redirecting the user towards the report page that will display the report.

Create a new web page called ViewReport.aspx. From the toolbox drag the Crystal Report Viewer control on the form and name it crViewer. Here is how it looks:



In the properties window you will find some properties like DisplayToolbar, EnableDrillDown, EnableViewState. These properties help us to customize our report; for this example we set them all as false. We also need to write some code to pass the arguments to our report like the ItemId, StartDate and EndDate, which we will do later. Save the form and close it. Before we go any further, we will create the report.

Creating the Report
Right click on the solution name in the project explorer and click Add | Add New Item | CrystalReport. Name it ItemReport. Next we will be asked to select how our report is created. We will use the Report Expert, which is the default option. From the down options we can select the format of your report. Select "Standard" which is again the default. The next screen shows this:



We then have to select our data source. Select OLEDB (ADO) | Microsoft OLE DB Provider for SQL Server | Next. We need to provide the Server name, our UserId and Password, and the database to which we want to connect. After providing the information, click Finish.

Now you need to select the tables to which we will be displaying data. For our example, select "tblSales " only because all the data we need is from this table. Here is the screen.



Click Next to proceed. Now we have to add the fields to be displayed in the report. Select SaleDate and Amount. Click Next we will be offered the option to Group the information on the report using a Group By clause. We do not need this so just click Next again.

Next we have to select our chart type. There are a large number of different charts available. For our example, select Line and the first chart type and click Finish.



This is what you will see.



Right click on the Page Header area and click Insert | Chart. We will see a screen that we have already seen before. Click on the Data tab.



We mention here that we want only one chart in our report. Then we provide our SaleDate field under the On change of column. Note that we mention both the fields that we want to be displayed (SaleDate and Amount). Click on the Text tab and select a suitable Title for your report. Click Ok and we are almost done. We need to set the output parameters our code will query - so let's do that next.
blog comments powered by Disqus
C# ARTICLES

- Introduction to Objects and Classes in C#, P...
- Visual C#.NET, Part 1: Introduction to Progr...
- C# - An Introduction
- Hotmail Exposed: Access Hotmail using C#
- Razor Sharp C#
- Introduction to Objects and Classes in C#
- Making Your Code CLS Compliant
- Programming with MySQL and .NET Technologies
- Socket Programming in C# - Part II
- Socket Programming in C# - Part I
- Creational Patterns in C#
- Type Conversions
- Creating Custom Delegates and Events in C#
- Inheritance and Polymorphism
- Understanding Properties in C#

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials