Display of data in multiple tables in the push mode of the Crystal Report

Source: Internet
Author: User

Currently, only one table of data can be generated in all the online sample reports. As mentioned in those examples, if you want to use the push mode to display data in two tables in the report, there will be a "Logon Failure" problem. In fact, these examples describe the relationship between dataset and the database very closely. This gives us the illusion that the dataset will have the same structure as the database. Actually, in the push mode, dataset has nothing to do with the database. The reason for creating this dataset is to allow you to edit the RPT template. The data shown at the end is all in the background.Code. It has nothing to do with the database at design time. Therefore, the dataset part created in the original example should be modified to the following steps:

1. Add a new item in Solution Explorer, select a dataset, set the file name, and click OK.

2. Right-click the Dataset Designer and select "create element". In this step, a table is added ., Set the table name.

 

3. Add the corresponding fields in the newly created table. The field name and field type must match the field you want to display. Otherwise, problems may occur.

 

4. The remaining steps are the same as those in the original tutorial. Select "project data-ADO. Net dataset" from the database expert. The following shows the database and table you just created. Select the table to the selected table. Create a report template as you wish. In the background code, use the dataset you have extracted from the database to fill the report. OK!

With the original online example content:

Create a DataSet object from a database

 

1. Create a new architecture file in the project:

 

A. in Solution Explorer, right-click the project name, point to "add", and click "Add new project ".

B. In the "category" Area of the "Add new project" dialog box, expand the folder and select "data ".

 

C. Select "dataset" in the "template" area ".

 

D. Accept the default name dataset1.xsd.

 

This creates a new schema file (dataset1.xsd), which will be used to generate a strong dataset. The schema file is displayed in the ADO. Net Dataset Designer.

 

2. Specify the database location:

 

A. in server resource manager, right-click "Data Connection" and select "add connection ".

 

B. In the "Data Link Properties" dialog box, click "provideProgram"Tab, and then select a provider (for example, Microsoft ole db provider for SQL Server ).

 

C. Click the connection tab and specify the location of your database. Enter the server and logon information at the required location.

 

D. Click OK.

 

In this case, your database, its tables, and fields appear under the "Data Connection" node of the server resource manager.

3. In Solution Explorer, double-click dataset1.xsd (if it is not an active view yet ).

Dataset1.xsd should now be displayed on the dataset tab.

4. To create a schema for a dataset, drag the required table from the server resource manager to the dataset tab of dataset1.xsd.

5. Click "Save dataset1.xsd" to save the "dataset1.xsd" file.

6. On the "generate" menu, click "generate" to generate a DataSet object for the project.

The ADO. Net DataSet object provides a description of the data from which tables can be added to the Crystal Report. Use "database experts" in Crystal Report designer to add tables from ADO. Net dataset objects.

Call "Database Expert" when using "report expert" to create a new report ". Or, you must use ADO. to access "database experts" in a report created by. net, right-click report designer, point to "Database", and click "Add/delete database ".

Connect a report to an ADO. Net DataSet object

1. Expand the project data folder in "database experts.

2. Expand the "ADO. Net dataset" folder.

3. Select the expected DataSet object.

For example, if you are using a DataSet object generated from the project "dataset1.xsd" architecture file "windowsapplication1", you should select "windowsapplication1.dataset1 ".

4. Select the table to be added to the report, just like using other data sources.

Dynamically change data source code

Dim dsdataset as new dataset ()

Dim orpt as new rptclient () 'created report rptclient

Please fill in the dsdataset dataset by yourself

'Use the report engine object model to pass the filled dataset to the report.

Orpt. setdatasource (dsdataset. Tables (0 ))

'Bind a report object with data to Windows form viewer, rptvew (crystalreportviewer Control)

Rptvew. reportsource = orpt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.