Use Crystal Report in asp.net (on)

Source: Internet
Author: User
Tags expression connect net bug visual studio
Asp.net| Crystal Report Before we studied the Crystal Report in Vs.net (Crystal Reports), my friends and I were very curious about how to add this complex to our web application. A week later, after reading a lot of "HOWTO" documents, we succeeded in adding some simple reports to our ASP.net program and getting some tips.

This article teaches you how to use Crystal Reports in. Net Web applications, and lets you take fewer detours in your learning process. To get the best results, readers need some basic asp.net access to the database as well as the use of vs.net development experience.

Brief introduction

Crystal Reports can be obtained in a number of ways, one of which is created using Vs.net, which provides a very rich model so that we can manipulate properties and methods at run time. If you are using vs.net to develop. NET programs, then you will not need to install other software because he is already embedded in the vs.net.

Advantages:

Vs. NET Crystal Report has some of the following major advantages:

Quick Report Development

Ability to export into complex interactive graphs

Can be used with other controls in WebForm

Ability to dynamically export a report to. pdf,.doc,xls,html,rtf and more formats

Structure:

Some components make up the two-tier structure of the Crystal Report, and the required Web applications are:

Client:

The client only needs a browser that can access the embedded ASPX page report.

Server:

Crystal Reporting Engine (Crystal report Engine (CREngine.dll))

It allows you to accomplish tasks such as merging data in a report file, converting reports to other formats, and so on. It is also precisely because of the role of the reporting engine that the Crystal report in ASP.net can be converted into normal HTML format

Crystal Reports Designer (Crystal report Designer (CRDesigner.dll))

Crystal Reports are created in the designer, in which you can design headings, insert data, formulas, graphs, subreports, and so on.

. RPT Report File

The first step in performing a report is to create this report in the Crystal Report Designer interface, and Microsoft has provided some out-of-the-box examples in the default installation. Rpt.

Data Source

The method of getting a database from a RPT file depends on your choice of method, you can choose to let the Crystal Report select the data without using any code, or you can choose to assemble the dataset manually, and then transfer it to the report file.

Crystal Reports view Controls (Crystal Report Viewer Web Form Control (CRWebFormViewer.dll))

Crystal Report The View control is a WebForm control that can be viewed as a container for storing reports in an. aspx page. Note: In some complex operations, the report server and the Web server may not be on the same physical host, and the Web server transmits HTTP requests to the report server. Crystal Reports can also be executed as WebService.

Execution mode

Crystal Report data can be implemented using the following methods:

Pull mode:

When requested, the Crystal Report connects the database directly to the specified drive and assembles the data.

Push mode:

At this point, you have to write your own code to connect the data and assemble the dataset, and send it to the report. In some cases, you can use report performance maximization by using Connection Sharing and limiting the size of the record collection.

Report type:

Crystal Report Designer can also use separate report objects by directly including reports to the project.

Strongly-typed Report:

When you add a report file to a project, it becomes a "strongly-typed" report. In these cases, you will have the power to directly create the report object, which will reduce some code and provide some performance.

Un-typed Report:

The reports here are not directly included in the project, so they are called ' un-typed ' reports. In this case, you have to use the Crystal Report "Reportdocuemt" object to create an instance, and "Manually" to the use of the report.

Other matters for attention

Although the Crystal Report Viewer has some cool features, such as scaling, page navigation, and so on. But he doesn't provide the print function, you have to call the browser's print function.

Vs. NET in the Crystal Report if not registered, then it can only use 30 times, 30 times, the "save" function can no longer use. To avoid this, you are not registering this product in http://www.crystaldecisions.com/. (as if not, not registered also seems to be able to use a long time, but can not provide support)

The default installed Crystal Report can only support 5 users, and in order to support more users, you have to purchase licenses in http://www.crystaldecisions.com/.


Let's feel it--using a ready-made Crystal report file in asp.net



Let's first feel the feeling of using the Crystal Report in WebForm.

1 Drag the Crystal Report Viewer control (Crystal) to the. aspx page from the WebForm toolbar.



 



2) pull up the Crystal Report Viewer control Properties window

3) Click [...] button to view the "Data Binding" property and eject the DataBinding window.

4 from the left side of the "Bindable Properties" area, select "" "

5 Select the custom binding Expression radio button and specify the file name and path for the. rpt file in the window at the bottom right, for example: "C:\\Program Files\\Microsoft Visual Studio.net\\crystal Reports\\ Samples\\reports\\general business\\world Sales report.rpt ", then" OK "



Note: The file "World Sales report.rpt" file was created at Vs.net installation. If you specify a different directory during the installation process, you may want to confirm the correctness of the path at this point.

The above steps actually insert the following code into the asp.net file:

<%@ Register tagprefix= "cr" Namespace= "Crystaldecisions.web" assembly= "Crystaldecisions.web"%>



And:

<CR:CRYSTALREPORTVIEWER>
Id= "CrystalReportViewer1"
runat= "Server" width= "350px" height= "50px"
Reportsource= ' <%# ' c:\\program Files\\Microsoft Visual Studio.net\\crystal Reports\\samples\\reports\\general Business\\world Sales report.rpt "%>"
</CR:CRYSTALREPORTVIEWER>



Note: In the automatic code generated in my Vs.net official version of the Flying Knife, the style produced by ReportSource is not like this, it is:

Reportsource= "<%# C:\xxxxx\xxx.rpt%>"



This is wrong, there are error messages, there are two errors:

DataBind must have double quotes, so only single quotes outside
Directory separator cannot use ' \ ', you must use ' \ '
You must modify it manually according to the format described in this article, which is a vs.net bug.

6) Call the DataBind method in the Page_Load method. (Code is vb.net)

Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs)

DataBind ()

End Sub




7 Save and compile your page. Now you have a WebForm page with a crystal report embedded in it.

Note: In actual development, an error in the Inetsrv directory cannot be accessed at first, and the solution is to change the security attributes of its directory so that the user has writable permissions. Flying knives, I found. NET system has been given the solution is not used, it may be that I am using the Windows.NET operating system reasons.




This article teaches you how to use Crystal Reports in. Net Web applications, and lets you take fewer detours in your learning process. To get the best results, readers need some basic asp.net access to the database as well as the use of vs.net development experience.

Brief introduction

Crystal Reports can be obtained in a number of ways, one of which is created using Vs.net, which provides a very rich model so that we can manipulate properties and methods at run time. If you are using vs.net to develop. NET programs, then you will not need to install other software because he is already embedded in the vs.net.

Advantages:

Vs. NET Crystal Report has some of the following major advantages:

Quick Report Development

Ability to export into complex interactive graphs

Can be used with other controls in WebForm

Ability to dynamically export a report to. pdf,.doc,xls,html,rtf and more formats

Structure:

Some components make up the two-tier structure of the Crystal Report, and the required Web applications are:

Client:

The client only needs a browser that can access the embedded ASPX page report.

Server:

Crystal Reporting Engine (Crystal report Engine (CREngine.dll))

It allows you to accomplish tasks such as merging data in a report file, converting reports to other formats, and so on. It is also precisely because of the role of the reporting engine that the Crystal report in ASP.net can be converted into normal HTML format

Crystal Reports Designer (Crystal report Designer (CRDesigner.dll))

Crystal Reports are created in the designer, in which you can design headings, insert data, formulas, graphs, subreports, and so on.

. RPT Report File

The first step in performing a report is to create this report in the Crystal Report Designer interface, and Microsoft has provided some out-of-the-box examples in the default installation. Rpt.

Data Source

The method of getting a database from a RPT file depends on your choice of method, you can choose to let the Crystal Report select the data without using any code, or you can choose to assemble the dataset manually, and then transfer it to the report file.

Crystal Reports view Controls (Crystal Report Viewer Web Form Control (CRWebFormViewer.dll))

Crystal Report The View control is a WebForm control that can be viewed as a container for storing reports in an. aspx page. Note: In some complex operations, the report server and the Web server may not be on the same physical host, and the Web server transmits HTTP requests to the report server. Crystal Reports can also be executed as WebService.

Execution mode

Crystal Report data can be implemented using the following methods:

Pull mode:

When requested, the Crystal Report connects the database directly to the specified drive and assembles the data.

Push mode:

At this point, you have to write your own code to connect the data and assemble the dataset, and send it to the report. In some cases, you can use report performance maximization by using Connection Sharing and limiting the size of the record collection.

Report type:

Crystal Report Designer can also use separate report objects by directly including reports to the project.

Strongly-typed Report:

When you add a report file to a project, it becomes a "strongly-typed" report. In these cases, you will have the power to directly create the report object, which will reduce some code and provide some performance.

Un-typed Report:

The reports here are not directly included in the project, so they are called ' un-typed ' reports. In this case, you have to use the Crystal Report "Reportdocuemt" object to create an instance, and "Manually" to the use of the report.

Other matters for attention

Although the Crystal Report Viewer has some cool features, such as scaling, page navigation, and so on. But he doesn't provide the print function, you have to call the browser's print function.

Vs. NET in the Crystal Report if not registered, then it can only use 30 times, 30 times, the "save" function can no longer use. To avoid this, you are not registering this product in http://www.crystaldecisions.com/. (as if not, not registered also seems to be able to use a long time, but can not provide support)

The default installed Crystal Report can only support 5 users, and in order to support more users, you have to purchase licenses in http://www.crystaldecisions.com/.


Let's feel it--using a ready-made Crystal report file in asp.net



Let's first feel the feeling of using the Crystal Report in WebForm.

1 Drag the Crystal Report Viewer control (Crystal) to the. aspx page from the WebForm toolbar.



 



2) pull up the Crystal Report Viewer control Properties window

3) Click [...] button to view the "Data Binding" property and eject the DataBinding window.

4 from the left side of the "Bindable Properties" area, select "" "

5 Select the custom binding Expression radio button and specify the file name and path for the. rpt file in the window at the bottom right, for example: "C:\\Program Files\\Microsoft Visual Studio.net\\crystal Reports\\ Samples\\reports\\general business\\world Sales report.rpt ", then" OK "



Note: The file "World Sales report.rpt" file was created at Vs.net installation. If you specify a different directory during the installation process, you may want to confirm the correctness of the path at this point.

The above steps actually insert the following code into the asp.net file:

<%@ Register tagprefix= "cr" Namespace= "Crystaldecisions.web" assembly= "Crystaldecisions.web"%>



And:

<CR:CRYSTALREPORTVIEWER>
Id= "CrystalReportViewer1"
runat= "Server" width= "350px" height= "50px"
Reportsource= ' <%# ' c:\\program Files\\Microsoft Visual Studio.net\\crystal Reports\\samples\\reports\\general Business\\world Sales report.rpt "%>"
</CR:CRYSTALREPORTVIEWER>



Note: In the automatic code generated in my Vs.net official version of the Flying Knife, the style produced by ReportSource is not like this, it is:

Reportsource= "<%# C:\xxxxx\xxx.rpt%>"



This is wrong, there are error messages, there are two errors:

DataBind must have double quotes, so only single quotes outside
Directory separator cannot use ' \ ', you must use ' \ '
You must modify it manually according to the format described in this article, which is a vs.net bug.

6) Call the DataBind method in the Page_Load method. (Code is vb.net)

Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs)

DataBind ()

End Sub




7 Save and compile your page. Now you have a WebForm page with a crystal report embedded in it.

Note: In actual development, an error in the Inetsrv directory cannot be accessed at first, and the solution is to change the security attributes of its directory so that the user has writable permissions. Flying knives, I found. NET system has been given the solution is not used, it may be that I am using the Windows.NET operating system reasons.




This article teaches you how to use Crystal Reports in. Net Web applications, and lets you take fewer detours in your learning process. To get the best results, readers need some basic asp.net access to the database as well as the use of vs.net development experience.

Brief introduction

Crystal Reports can be obtained in a number of ways, one of which is created using Vs.net, which provides a very rich model so that we can manipulate properties and methods at run time. If you are using vs.net to develop. NET programs, then you will not need to install other software because he is already embedded in the vs.net.

Advantages:

Vs. NET Crystal Report has some of the following major advantages:

Quick Report Development

Ability to export into complex interactive graphs

Can be used with other controls in WebForm

Ability to dynamically export a report to. pdf,.doc,xls,html,rtf and more formats

Structure:

Some components make up the two-tier structure of the Crystal Report, and the required Web applications are:

Client:

The client only needs a browser that can access the embedded ASPX page report.

Server:

Crystal Reporting Engine (Crystal report Engine (CREngine.dll))

It allows you to accomplish tasks such as merging data in a report file, converting reports to other formats, and so on. It is also precisely because of the role of the reporting engine that the Crystal report in ASP.net can be converted into normal HTML format

Crystal Reports Designer (Crystal report Designer (CRDesigner.dll))

Crystal Reports are created in the designer, in which you can design headings, insert data, formulas, graphs, subreports, and so on.

. RPT Report File

The first step in performing a report is to create this report in the Crystal Report Designer interface, and Microsoft has provided some out-of-the-box examples in the default installation. Rpt.

Data Source

The method of getting a database from a RPT file depends on your choice of method, you can choose to let the Crystal Report select the data without using any code, or you can choose to assemble the dataset manually, and then transfer it to the report file.

Crystal Reports view Controls (Crystal Report Viewer Web Form Control (CRWebFormViewer.dll))

Crystal Report The View control is a WebForm control that can be viewed as a container for storing reports in an. aspx page. Note: In some complex operations, the report server and the Web server may not be on the same physical host, and the Web server transmits HTTP requests to the report server. Crystal Reports can also be executed as WebService.

Execution mode

Crystal Report data can be implemented using the following methods:

Pull mode:

When requested, the Crystal Report connects the database directly to the specified drive and assembles the data.

Push mode:

At this point, you have to write your own code to connect the data and assemble the dataset, and send it to the report. In some cases, you can use report performance maximization by using Connection Sharing and limiting the size of the record collection.

Report type:

Crystal Report Designer can also use separate report objects by directly including reports to the project.

Strongly-typed Report:

When you add a report file to a project, it becomes a "strongly-typed" report. In these cases, you will have the power to directly create the report object, which will reduce some code and provide some performance.

Un-typed Report:

The reports here are not directly included in the project, so they are called ' un-typed ' reports. In this case, you have to use the Crystal Report "Reportdocuemt" object to create an instance, and "Manually" to the use of the report.

Other matters for attention

Although the Crystal Report Viewer has some cool features, such as scaling, page navigation, and so on. But he doesn't provide the print function, you have to call the browser's print function.

Vs. NET in the Crystal Report if not registered, then it can only use 30 times, 30 times, the "save" function can no longer use. To avoid this, you are not registering this product in http://www.crystaldecisions.com/. (as if not, not registered also seems to be able to use a long time, but can not provide support)

The default installed Crystal Report can only support 5 users, and in order to support more users, you have to purchase licenses in http://www.crystaldecisions.com/.


Let's feel it--using a ready-made Crystal report file in asp.net



Let's first feel the feeling of using the Crystal Report in WebForm.

1 Drag the Crystal Report Viewer control (Crystal) to the. aspx page from the WebForm toolbar.



 



2) pull up the Crystal Report Viewer control Properties window

3) Click [...] button to view the "Data Binding" property and eject the DataBinding window.

4 from the left side of the "Bindable Properties" area, select "" "

5 Select the custom binding Expression radio button and specify the file name and path for the. rpt file in the window at the bottom right, for example: "C:\\Program Files\\Microsoft Visual Studio.net\\crystal Reports\\ Samples\\reports\\general business\\world Sales report.rpt ", then" OK "



Note: The file "World Sales report.rpt" file was created at Vs.net installation. If you specify a different directory during the installation process, you may want to confirm the correctness of the path at this point.

The above steps actually insert the following code into the asp.net file:

<%@ Register tagprefix= "cr" Namespace= "Crystaldecisions.web" assembly= "Crystaldecisions.web"%>



And:

<CR:CRYSTALREPORTVIEWER>
Id= "CrystalReportViewer1"
runat= "Server" width= "350px" height= "50px"
Reportsource= ' <%# ' c:\\program Files\\Microsoft Visual Studio.net\\crystal Reports\\samples\\reports\\general Business\\world Sales report.rpt "%>"
</CR:CRYSTALREPORTVIEWER>



Note: In the automatic code generated in my Vs.net official version of the Flying Knife, the style produced by ReportSource is not like this, it is:

Reportsource= "<%# C:\xxxxx\xxx.rpt%>"



This is wrong, there are error messages, there are two errors:

DataBind must have double quotes, so only single quotes outside
Directory separator cannot use ' \ ', you must use ' \ '
You must modify it manually according to the format described in this article, which is a vs.net bug.

6) Call the DataBind method in the Page_Load method. (Code is vb.net)

Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs)

DataBind ()

End Sub




7 Save and compile your page. Now you have a WebForm page with a crystal report embedded in it.

Note: In actual development, an error in the Inetsrv directory cannot be accessed at first, and the solution is to change the security attributes of its directory so that the user has writable permissions. Flying knives, I found. NET system has been given the solution is not used, it may be that I am using the Windows.NET operating system reasons.


Related Article

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.