Building Reports Using ASP.NET and Crystal Reports - Part 2 - Quarterly Sales Report
page 4 of 15
by Vince Varallo
Feedback
Average Rating: 
Views (Total / Last 10 Days): 64276/ 99

Step 3: Connect to the database

The first step in designing this report is connecting to the AdventureWorks database and bringing in the tables that you need. These steps assume you have already downloaded and run the install for the AdventureWorks database.

1.    Right click on the Database Fields node in the Field Explorer. If you do not see the Field Explorer window, select Crystal ReportsàField Explorer from the menu. Select Database Expert… from the pop-up menu.

2.    This report is going to connect directly to the database using OLE DB. To connect to the database click the plus sign next to the Create New Connection node.

3.    Click the plus sign next to OLE DB (ADO). This will display the OLE DB dialog which allows you to select your AdventureWorks database.

4.    Select SQL Native Client from the list of providers and click Next.

5.    Enter the server name where the SQL Server database is installed.

6.    You can either use integrated security or a SQL Login and password to connect to the database. This depends on how you setup your database when you installed it. I created a SQL Login called "aspalliance," gave it a password of "aspalliance" and added the Login to the db_owner role in the AdventureWorks database. Enter the User ID and Password.

7.    Now click on the Database drop down list. You should see AdventureWorks as one of the options. If you do not then the SQL Login does not have access to the database. You will have to use SQL Server Management Studio to add the aspalliance Login and add them to the db_owner role for the AdventureWorks database.

8.    Once you have selected AdventureWorks for the database, click Next and then click Finish.

Your SQL Server should appear under the OLE DB (ADO) node and the AdventureWorks database should be listed under the server name.

Figure 3

 

9.    Click the plus sign next to AdventureWorks and you will see the list of schemas defined in the database. If you click the plus sign next to a schema name, you will see two nodes, one for Tables and one for Views. Clicking the plus sign next to either will display the list of tables or views in that schema.

10. The next step is to select the appropriate tables and views for the report and move them to the Selected Tables list in the dialog box. Expand the Person schema and the Tables. Click on the Contact table and then click the > button to move this table to the Selected Tables list.  Do the same for the HumanResources.Employee, Sales.SalesOrderHeader, Sales.SalesPerson, and Sales.SalesTerritory tables.

11. Now that you have selected the tables, you need to define the relationships between these tables. Crystal does a pretty good job of figuring this out, but cannot figure everything out automatically. To manually configure the relationships click the Links tab in the Database Expert dialog.

12. This displays a graphical representation of the tables. You can make the dialog box bigger by dragging the lower right hand corner of the dialog box. I like to make this big so I can see as many tables as possible.

13. Crystal should have figured out the relationships between the SalesOrderHeader.SalesPersonId and SalesPerson.SalesPersonId, the SalesPerson.SalesPersonId and Employee.EmployeeId, the Employee.ContactId and Contact.ContactId, and the SalesPerson.TerritoryId and SalesTerritory.TerritoryId tables. You should see a line between the primary and foreign keys between these tables. If you do not, you can easily create the relationship by clicking on the foreign key field and dragging it to the primary key field. You will need to remove the relationships between the SalesOrderHeader.ContactId and the Contact.ContactId, and the relationship between the SalesOrderHeader.TerritoryId and the SalesTerritory.TerritoryID.

Figure 4

14. Click the OK button.

You should now see the report in Visual Studio 2008. Click the plus sign next to the Database Fields node in the Field Explorer. You see all your tables listed. Click the plus sign next to a table and you will see the fields in that table. These are now available to be used in the report.


View Entire Article

User Comments

Title: specialized in wholesale cheap nike nfl jerseys   
Name: wholesale cheap jerseys
Date: 2012-08-06 4:16:47 AM
Comment:
we are specialized in wholesale cheap nike nfl jerseys , nfl jerseys , mlb jerseys , nhl jerseys , nba jerseys , soccer jerseys ,hoodies, sports caps.

http://jerseymember.com/Nike-NFL-Jersey-c134.html

http://jerseymember.com/NFL-Jersey-c68.html

http://jerseymember.com/MLB-Jerseys-c94.html

http://jerseymember.com/NHL-Jerseys-c96.html

http://jerseymember.com/NBA-Jerseys-c77.html

http://jerseymember.com/NCAA-Jersey-c114.html

http://jerseymember.com/Soccer-Jerseys-c123.html

http://jerseymember.com/Customized-Jerseys-c116.html

http://jerseymember.com/Customized-Jerseys-c116.html

http://jerseymember.com/Hoodies-c136.html

http://jerseymember.com/Sports-Caps--c119.html

http://jerseymember.com/Others-c131.html
Title: nfl jerseys cheap   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:11:39 AM
Comment:
http://www.jersey2shop.com
http://www.cheapjersey2store.com
http://www.jerseycaptain.com
http://www.yourjerseyhome.com
We are professional jerseys manufacturer from china,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
Cheap NFL,NBA,MLB,NHL
,heap jerseys,2012 nike nfl Jerseys,nba jersey and shorts,oklahoma city thunder jersey,official jeremy lin new york knicks jersey,NFL Jerseys Wholesale,blake griffin jersey blue,NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
,Wholesale cheap jerseys,Cheap mlb jerseys,]Nike NFL Jerseys,Cheap China Wholesae,Wholesale jerseys From China,2012 nike nfl Jerseys,Jerseys From China,,2012 nike nfl Jerseys,Revolution 30 nba jerseys,jersey of nba chicago bulls direk rose ,nfl jerseys,green bay packers jerseys wholesale,Buffalo Bills nike nfl jerseys sale,good supplier soccer jerseys,cool base mlb jerseys,Revolution 30 nba jerseys,2012 stanley cup nhl jersey,
We are professional jerseys manufacturer from china,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes. www.yourjerseyhome.com
Title: 2012 NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:10:03 AM
Comment:
http://www.jersey2shop.com
http://www.cheapjersey2store.com
http://www.jerseycaptain.com
http://www.yourjerseyhome.com
We are professional jerseys manufacturer from china,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
Cheap NFL,NBA,MLB,NHL
,heap jerseys,2012 nike nfl Jerseys,nba jersey and shorts,oklahoma city thunder jersey,official jeremy lin new york knicks jersey,NFL Jerseys Wholesale,blake griffin jersey blue,NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
,Wholesale cheap jerseys,Cheap mlb jerseys,]Nike NFL Jerseys,Cheap China Wholesae,Wholesale jerseys From China,2012 nike nfl Jerseys,Jerseys From China,,2012 nike nfl Jerseys,Revolution 30 nba jerseys,jersey of nba chicago bulls direk rose ,nfl jerseys,green bay packers jerseys wholesale,Buffalo Bills nike nfl jerseys sale,good supplier soccer jerseys,cool base mlb jerseys,Revolution 30 nba jerseys,2012 stanley cup nhl jersey,
We are professional jerseys manufacturer from china,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes. www.yourjerseyhome.com
Title: asp   
Name: sumti
Date: 2011-04-10 7:27:41 AM
Comment:
very nice code
Title: Nice Article   
Name: Rick
Date: 2009-12-01 11:18:40 AM
Comment:
The example was very easy to understand and follow, thanks for taking the time to put these together.
Title: Awesome   
Name: Rusty
Date: 2009-08-27 10:36:14 AM
Comment:
Awesome job. I am a brand new CR user and I found your article to be easy to understand, follow, and very helpful. Thanks and keep them coming.
Title: Superb   
Name: ramakrishna
Date: 2009-08-01 6:51:52 AM
Comment:
This article is very good to customise my website,
Title: great work   
Name: Ankit Agarwal
Date: 2009-07-28 12:48:39 AM
Comment:
u have done a great work
this article is really helpful
Title: Great Job   
Name: yin min
Date: 2009-07-26 5:52:54 AM
Comment:
Thanks for your step by step article.
Everyone who is new at crystal are looking for such a simple and very useful article.
Thanks again.
Title: Well Done   
Name: Muhammad Aijaz Rajput
Date: 2009-07-10 10:47:53 AM
Comment:
This is an excellent article. Thanks. I realy need the detailed step-by-step article approach that you take.
Title: Source coming soon   
Name: Vince
Date: 2009-06-22 9:20:19 AM
Comment:
The source should be posted soon.
Title: Excellent   
Name: Walter
Date: 2009-06-16 4:03:31 AM
Comment:
Hi Vince,

another excellent article. Thanks. I really like the detailed step-by-step approach that you take.

Will the source be available as a download?

Regards

Product Spotlight
Product Spotlight 



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


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 5:33:48 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search