More Related Content
Similar to Vb.net session 08 (20)
Vb.net session 08
- 1. Creating Crystal Reports
Pre-Assessment Questions
1. Consider the following statements:
• Statement A: A dataset can maintain four versions of a DataRow object.
• Statement B: The four versions are Original, Current, Proposed, and
Default.
Which of the following is correct with respect to the above statements?
a. Both, Statement A and Statement B, are False.
b. Both, Statement A and Statement B, are True.
c. Statement A is True and Statement B is False.
d. Statement A is False and Statement B is True.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 1 of 30
- 2. Creating Crystal Reports
Pre-Assessment Questions (Contd.)
2. Consider the following statements:
• Statement A: The AcceptChanges() method is called for a dataset to
accept all the changes made to the dataset.
• Statement B: When the AcceptChanges() method is called, it overwrites
the current version of a record with the proposed version.
Which of the following is correct with respect to the above statements?
a. Both, Statement A and Statement B, are False.
b. Both, Statement A and Statement B, are True.
c. Statement A is True and Statement B is False.
d. Statement A is False and Statement B is True.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 2 of 30
- 3. Creating Crystal Reports
Pre-Assessment Questions (Contd.)
3. Consider the following statements:
• Statement A: In Pessimistic concurrency control, a system of locks
applied does not allow users to modify data in a way that affects other
users.
• Statement B: Pessimistic concurrency can be implemented in a
disconnected architecture.
Which of the following is correct with respect to the above statements?
a. Both, Statement A and Statement B, are False.
b. Both, Statement A and Statement B, are True.
c. Statement A is True and Statement B is False.
d. Statement A is False and Statement B is True.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 3 of 30
- 4. Creating Crystal Reports
Pre-Assessment Questions (Contd.)
4. Consider the following statements:
• Statement A: In Optimistic concurrency control, the lock is applied
when the users read the data.
• Statement B: Optimistic concurrency is used in environments where the
data contention is high.
Which of the following is correct with respect to the above statements?
a. Both, Statement A and Statement B, are False.
b. Both, Statement A and Statement B, are True.
c. Statement A is True and Statement B is False.
d. Statement A is False and Statement B is True.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 4 of 30
- 5. Creating Crystal Reports
Pre-Assessment Questions (Contd.)
5. Consider the following statements:
• Statement A: ADO.NET implements optimistic concurrency by using the
two methods Version Number method and Saving all values method.
• Statement B: By default, the data adapters that are created in an
ADO.NET application implement optimistic concurrency.
Which of the following is correct with respect to the above statements?
a. Both, Statement A and Statement B, are False.
b. Both, Statement A and Statement B, are True.
c. Statement A is True and Statement B is False.
d. Statement A is False and Statement B is True.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 5 of 30
- 6. Creating Crystal Reports
Solutions to Pre-Assessment
Questions
1. b. Both, Statement A and Statement B, are True.
2. c. Statement A is True and Statement B is False.
3. c. Statement A is True and Statement B is False.
4. a. Both, Statement A and Statement B, are False.
5. b. Both, Statement A and Statement B, are True.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 6 of 30
- 7. Creating Crystal Reports
Objectives
In this lesson, you will learn to:
• Access data through crystal reports
• Create a crystal report manually
• Use the Standard Report Expert
• Create a report from an existing report
• Enhance the crystal report
• Host a crystal report in the windows application
• View the crystal report
• Access filtered data through crystal reports
• Access related data through crystal reports
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 7 of 30
- 8. Creating Crystal Reports
Understanding Crystal Reports
• Crystal Reports is the standard reporting tool for Visual Studio .NET used to
display data of presentation quality.
• Creating a Crystal Report requires minimal coding since it is created in a
Designer interface.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 8 of 30
- 9. Creating Crystal Reports
Data Access Through Crystal Reports
• Crystal Reports need database drivers to connect to the data source for
accessing data.
• Crystal Reports in Visual Basic .NET support two methods to access data from
a data source:
• The Pull Model
• The Push Model
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 9 of 30
- 10. Creating Crystal Reports
The Pull Model
• When Pull model is used to access data from the data source, the database
driver directly retrieves the data from the data source.
• Pull model does not require the developer to write code for creating a
connection and retrieving data from the data source.
• The Crystal Report creates and manages the SQL commands for connecting to
the data source and retrieving data from it.
CRYSTAL DATA SOURCE
REPORT
DATA
The Pull Model
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 10 of 30
- 11. Creating Crystal Reports
The Push Model
• In this model, the developer writes the code to connect to the data source and
retrieve data from it.
• The data from the data source is cached in a dataset.
• the Push model allows filtered data access by Crystal Report.
• The Push model is generally useful for connection sharing scenarios.
CRYSTAL DATASET DATA
REPORT Data Data SOURCE
The push model
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 11 of 30
- 12. Creating Crystal Reports
Creating Crystal Reports
• Crystal Report can be created by using three methods:
• Manually
• Using Standard Report Expert
• From an existing report
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 12 of 30
- 13. Creating Crystal Reports
Creating a Crystal Report Manually
• To create a Crystal Report manually, user can perform the following steps:
• Right-click the project name in the Solution Explorer window and select
Add Add New Item from the shortcut menu option.
• The Add New Item - <Application name> dialog box is displayed.
Select Crystal Report from the Templates pane.
• Name the Crystal Report as required and click the Open button, the
Crystal Report Gallery is displayed.
• Crystal Report Gallery displays three radio buttons, which are discussed
below:
• Using the Report Expert
• As a Blank Report
• From an Existing Report
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 13 of 30
- 14. Creating Crystal Reports
Creating a Crystal Report
Manually(Contd.)
• The Report Designer is displayed with the sections Report Header,
Page Header, Details, Report Footer, and Page Footer.
• User can connect to a database and select the fields from the database
table to be displayed in the Crystal Report.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 14 of 30
- 15. Creating Crystal Reports
Using Standard Report Expert
• To create a Crystal Report by using Standard Report Expert, perform the
following steps:
• Select Crystal Report in the Add New Item - <Application name>
dialog box and click the Open button.
• Then, Select the Using the Report Expert option from Crystal Report
Gallery and click the OK button.
• Standard Report Expert appears and insert the tables.
• After inserting the tables, click the Next button. The Fields tab is
displayed and fields can be selected by selecting the field and clicking the
(Add ->) button.
• After the fields to be displayed in the Crystal Report are selected, the
various tabs under Standard Report Expert are added.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 15 of 30
- 16. Creating Crystal Reports
Creating Report from an Existing
Report
• To create a report based on the design of an existing report, you can
perform the following steps:
• Select the Crystal Report in the Add New Item - <Application
name> dialog box and click the Open button.
• Then, select the From an Existing Report option from Crystal Report
Gallery and click OK button.
• The Open dialog box is displayed. Select the existing Crystal Report file
and click the Open button.
• The Report Designer is displayed with the design of the selected file.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 16 of 30
- 17. Creating Crystal Reports
Enhancing the Crystal Reports
• The presentation quality of a Crystal Report can be enhanced by adding the
following components to the Crystal Report:
• Charts
• Cross-tabs
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 17 of 30
- 18. Creating Crystal Reports
Hosting the Crystal Report in the
Windows Application
• A Crystal Report can be hosted in a Windows Form by using the Windows
Forms Viewer.
• The Windows Forms Viewer is present as a control in the Toolbox and
contains the following components:
• Toolbar
• Export Report
• Toggle Group Tree
• Zoom
• Search Text
• Group Tree
• Main Report window
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 18 of 30
- 19. Creating Crystal Reports
Adding a Windows Forms Viewer to
the Windows Form
• Follow the given steps to add a Windows Forms Viewer to the Windows
Form:
• From the Windows Forms tab of the Toolbox, drag the
CrystalReportViewer control into the form and name it as
RevenueReportViewer.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 19 of 30
- 20. Creating Crystal Reports
Binding the CrystalReportViewer
Control to the Created Crystal
Report
• To do binding, follow the given steps:
• In Properties window under the Misc category, click the
ReportSource property and specify the source from where the
Crystal Report would be accessed.
• In Open an Existing Crystal Report dialog box dialog box,
Select the report and click the Open button.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 20 of 30
- 21. Creating Crystal Reports
Viewing the Crystal Report
• To view the Crystal Report data, select Debug from the menu bar. Then,
select Start from the Debug menu.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 21 of 30
- 22. Creating Crystal Reports
Demo
Accessing Filtered Data through
Crystal Reports
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 22 of 30
- 23. Creating Crystal Reports
Problem Statement
• The Sales Manager of Diaz Telecommunications needs to view a summarized
report containing the order details for the products with sale price greater
than $3000 to identify the potential market for the products in the coming
period. In addition, the Sales Manager also needs to view the percentage of
the sale price paid as advance for each order.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 23 of 30
- 24. Creating Crystal Reports
Solution
• To create the required application, perform following tasks:
1. Retrieve the filtered data from the database.
2. Create a crystal report manually and group the data.
3. Create the formula for calculating percentage.
4. Host the Crystal Report.
5. Write the code to connect to the database at run time.
6. View the Crystal report.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 24 of 30
- 25. Creating Crystal Reports
Demo
Accessing Related Data Through
Crystal Reports
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 25 of 30
- 26. Creating Crystal Reports
Problem Statement
• The Sales Manager of Diaz Telecommunications needs to view a summarized
product-wise order details report. The product name for each product also
needs to be displayed in the report.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 26 of 30
- 27. Creating Crystal Reports
Solution
• To create the required application, perform following tasks:
1. Create a Crystal Report
2. Host the Crystal Report.
3. View the Crystal report.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 27 of 30
- 28. Creating Crystal Reports
Summary
In this lesson, you learned that:
• A Crystal Report is a standard reporting tool for Visual Studio .NET used to
display data of presentation quality.
• Crystal Reports use database drivers to connect with the data source for
accessing data.
• Crystal Reports in Visual Basic .NET supports two methods to access data
from a data source:
• The Pull model
• The Push model
• The presentation quality of a Crystal Report can be enhanced by adding the
following components to the Crystal Report:
• Chart
• Cross-tab
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 28 of 30
- 29. Creating Crystal Reports
Summary (Contd.)
• A Crystal Report can be hosted in a Windows Form by using the Windows
Forms Viewer.
• Apart from allowing an easy viewing of the Crystal Report in a Windows
application, the Windows Forms Viewer also dynamically updates the
Crystal Report that is hosted.
• The Windows Forms Viewer can be inserted into a Windows application by
dragging the CrystalReportViewer control from the Toolbox into the form.
• The Windows Forms Viewer contains the following components:
• Toolbar
• Group Tree
• Main Report Window
• An interaction can be created between the Windows Forms Viewer and
other controls on the Windows Form by handling the events of the Windows
Form controls and the Windows Forms Viewer.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 29 of 30
- 30. Creating Crystal Reports
Summary (Contd.)
• An interaction can be created between the Windows Forms Viewer and
other controls on the Windows Form by handling the events of the Windows
Form controls and the Windows Forms Viewer.
• To display a Crystal Report, it has to be bound to a CrystalReportViewer
control.
• A Crystal Report can be bound to a CrystalReportViewer control by setting
the ReportSource property of the CrystalReportViewer control to the
path of the Crystal Report file.
©NIIT Creating Data Centric Application Using ADO.NET Lesson 2B / Slide 30 of 30