Create a Crystal Report from ADO.NET Dataset using Visual Basic .NET

Started by VelMurugan, Jul 26, 2008, 03:28 PM

Previous topic - Next topic

VelMurugan

Create a Crystal Report from ADO.NET Dataset using Visual Basic .NET

Introduction:

Crystal Report of Visual Studio .NET is the standard reporting tool for Visual Studio .NET. You can host reports on web and windows platform and can publish reports as Report Web services on the web server. It is based on framework of Crystal Report 8.0 and uses open and flexible architecture, with standards like XML, to allow porting reports over the web. Using crystal report expert you can choose report layouts, display charts, calculate summaries, subtotals as grouped data as well as conditionally format text and rotate text objects.

Although Crystal Reports for Visual Studio .NET supports variety of data source like ADO recordset, CDO recordset, DAO recordset, MS Excel workbook, this walkthrough endeavor to explain How to report off ADO.NET DataSet using Visual Basic .NET.

As you all know DataSet is the core component of distributed application and is explicitly designed for data access independent of any data source. Dataset can be created from variety of sources. Whatever the source is, before reporting off ADO.NET DataSet you must perform the following task:

#   Generate an object for the DataSet.
#   Connect report to DataSet Object.
#   Push data into DataSet Object.
#   Bind report to Windows Forms Viewer to display report with actual data at runtime.

Requirements:

#   Visual Studio .NET 2002
#   .NET Framework 1.0
#   SQL Server 2000 with Northwind database

Generating an Object for the DataSet

Object for ADO.NET is a collection of dataset classes created in memory.

To create a dataset object from Northwind database in SQL Server, using ADO.NET DataSet Designer.

1. In the Solution Explorer, right-click the project name, point to Add, and click Add New Item.
2. In the Categories area of the Add New Item dialog box, expand the folder and select Data.
3. In the Templates area, select Dataset.
4. Accept the default name Dataset1.xsd.

This creates a new schema file that will be used to generate a strongly typed dataset. The schema file will be displayed in ADO.NET Dataset designer.

5. In the Solutions Explorer, click on Dataset1.xsd file, if now already the active view.
6. From the Server Explore, on the right connect to SQL Server and drill down to Northwind Database.
7. Highlight the Table Customers (or stored procedure if desired) and drag and drop it on the Interface of Dataset1.xsd. Dataset1.xsd should now be displayed in the Dataset tab.

This creates a dataset object and contains only a description of the database based on the schema in Dataset1.xsd. It does not contain the actual data.