Using Crystal Reports and ASP.NET to Create Drill through Reports and Graphs
page 3 of 7
by Vince Varallo
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 40854/ 44

Step 2: Add the Crystal Report to Your Solution

1.    Right click on the web site in your Solution Explorer.

2.    Select Add New Item… from the pop-up menu.

3.    Click on Crystal Report from the templates.  If you don't see Crystal Report as an option then you need to run the Visual Studio 2008 installation and select the option to install Crystal Reports.  It comes free with Visual Studio 2008.

4.    Change the name of the report to Sales.rpt.  The Language drop down should already be set to Visual C# but if it isn't do so.

5.    Click the Add button.

Visual Studio will add the Crystal Report file to your web site and bring up the Crystal Reports Gallery dialog.  You may be prompted to register your product if this is the first time you're using Crystal Reports.  You can skip registering the product but it will keep prompting you every time you open a report so it's worth taking the extra minute or two to register.  Once you get to the Crystal Reports Gallery dialog you should select the "Using the Report Wizard" option and click OK.

The first step in the Report Wizard asks you to connect to a database.  Follow these steps to connect to the AdventureWorks database.

6.    Click the plus sign (+) next to the Create New Connection node.

7.    Click the plus sign next to the OLE DB (ADO) node.

8.    Another dialog box will appear.  This asks you which provider you want to use to connect to the database.  Scroll down the list and select SQL Native Client.  Click the Next button.

9.    The next screen allows you to enter the name of the database server, the SQL login, the password, and the database that you want to connect to. You should fill in your server name.  You can optionally use Integrated Security which means you'll connect to the database using your Windows Login. It doesn't matter if you use Integrated Security or a SQL Login as long as whichever you use has the correct permissions to read the tables in the database. I'll use Integrated Security for this example.

10. Click the Next button and then click the Finish button.

11. You should now see your server name appear under the OLE DB (ADO) node and the AdventureWorks database should appear under your server.

12. Click the plus sign next to the AdventureWorks database to view the list of schemas defined in the database.

13. Click the plus sign next to Sales and the click the plus sign next to Tables.

14. Scroll down and left click on the SalesOrderHeader table.  Click the > button to move this table to the list of selected tables.

15. Scroll up to the Person schema and add the Address, CountryRegion, and StateProvince tables to the list of selected tables.

16. Click the Next button.  The next screen allows you to define the links between the tables.  By default Crystal will try to figure out the links automatically.  Your screen should look like the following image.  If the links are not defined correctly than simply click and drag the fields to create a link between any two tables.  Once the links are defined you can click the Next button.

17. The next screen ask you to select the fields you want to display on the report.  These fields will be displayed in the Details section of the report.  Select the CountryRegion.Name, StateProvince.Name, Address.City, and SalesOrderHeader.TotalDue fields.  Click the > button to move the field in the Fields to Display list.

18. Click the Next button.  The next screen asks you which fields you want to group by.  For this report we want to show the data summarized at the Country level first, then by StateProvince, and then by the City.  This will create the drill through hierarchy we want to achieve in the web page.  Move the fields to the Group By list by clicking on the > button.

19. Click the Next button.  The next screen asks you which summary fields you would like to display on the report.  By default, Crystal will create a summary field for each group you defined in the previous screen.  Accept the default settings and click the Next button.

20. The next screen asks if you want to sort the groups.  Leave the default settings and click the Next button. 

21. The next screen asks if you want to add any charts to the report.  Leave this set to none for now.  Later in the article we'll add the graphs to the report.  Click the Next button.

22. The next screen allows you to specify selection criteria.  You use this if you want to filter the data on the report but we'll leave this blank.  Click the Next button.

23. The next screen allows you to select a layout for the report.  Leave the setting set to Standard and click the Finish button.  The report is now added to the project and should look like the following image.


View Entire Article

User Comments

Title: When must a company buy a license from SAP ?   
Name: Hans
Date: 2011-01-26 6:26:28 PM
Comment:
Hi

If a company wants to make a commercial web-site where the CrystalReportViewer in the web-site shows reports to the customers, must the company then buy a licence and if yes what kind of license? (Please give a link).

Example:
Let us for example assume that the commercial website is made like the example in this article ("Using Crystal Reports and ASP.NET to Create Drill through Reports and Graphs"). That is an ASP.NET (C#) application that shows results to the customers with CrystalReportViewer and the ASP.NET application runs on the company's server. The company's customers pay to access and see the results on the web-site (That is how the company earn money!).
Title: Version of Crystal Reports   
Name: Vince
Date: 2011-01-24 9:14:18 AM
Comment:
The sample was written in Visual Studio 2008 using Crystal Reports for .NET. This is the free version of Crystal Reports that comes with Visual Studio.
Title: Version of Crystal Report   
Name: N Pradeep kumar
Date: 2011-01-24 7:02:44 AM
Comment:
Please tell me the crystal reports version that supports drill down.
Title: An errror can occour in Visual Studioe 2010   
Name: Hans
Date: 2010-12-18 4:31:37 PM
Comment:
When I tryed to make the example in this article in Visual Studio 2010 i got an error when running the application (not when compiling):

Parser Error Message: The base class includes the field 'CrystalReportPartsViewer1', but its type (CrystalDecisions.Web.CrystalReportPartsViewer) is not compatible with the type of control (CrystalDecisions.Web.CrystalReportPartsViewer).

I solved the error by replacing the autogenerated line in Default.aspx (when adding a CrystalReportPartsViewer):

<%@ Register assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>

With this line:

<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>


So the version number that Visual Studio 2010 inserts when adding a CrystalReportPartsViewer is wrong. In my case it should be: 13.0.2000.0


I hope this can help others...

It is a good article. Thanks.
Title: hello..........Sir   
Name: Kaushal Bhasker
Date: 2010-11-17 6:21:52 AM
Comment:
This is very good........
i m agree whith this. all the way
Thanku......so much
Title: Problem in chart   
Name: kamlesh makvana
Date: 2010-09-14 3:58:12 AM
Comment:
how can i enable the don't summrized check box in chart using crystal report
Title: crystal report navigation   
Name: tanya
Date: 2010-06-22 3:33:55 AM
Comment:
i am using a crystal report for dynamic information
while i am running it only first page shows the data but i have thousands of records to be placed in crystal reports.
how can i place my record in second page of crystal report
Title: Crystal report export to excel, page header issue using asp.net visual studio 2008 sp1   
Name: MFiaz
Date: 2010-06-17 7:23:08 AM
Comment:
I have a Crystal report it has dynmic information on page header when I export to excel,

only first page header shows in excel. I am using asp.net visual studio 2008 sp1.

if I export it to others format like pdf, word etc... its working fine

lets assume

page header contanis

department name = 'Operations'
date = 16-06-2010

employee name code
xyz 1
eee 2
cxy 3

here cxy is related to department 'accounts'

if we see this data in pdf or word

it will show correctly

department name = 'Operations'
date = 16-06-2010

employee name code
xyz 1
eee 2


department name = 'Accounts'
date = 16-06-2010

employee name code
cxy 3


can you send me a sample?

Product Spotlight
Product Spotlight 



Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-23 6:33:00 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search