ramng, 10:26 How to Create Crystal Reports in ASPNET Webforms
How to Create Crystal Reports in
ASP.NET Webforms
12.Comments /8 minutes of reading / January 28, 2022
<_ Create Crystal Reports ASP.NET
Create Crystal Reports Visual MVC
Studio >
In this tutorial, we are going to discuss how to create a Crystal Report using ASP.NET
Web Form applications. We will show you how to create the Typed Dataset and bind
the Crystal Report to the Dataset in a Web Form application.
You can read our following tutorial on how to Create Crystal Reports
* How to Create Crystal Reports using Windows Forms Application
* How to Create Crystal Reports Using ASP.NET MVC Application
We are using Visual Studio 2013 and SAP Crystal Reports for Developer Edition to
Visual Studio. Click to Download Crystal Report for Visual Studi
under Visual Studio 2015 Community Edition and the latest version of Crystal Reports.
The Code also works
We are using the Northwind Database. You can download it from CodePlex
Table of Contents
Create the ASP.NET Web Forms Application
tps www tktutoralshub.comierystalreportsMow-o-create-cystalrepors-n-asp.net-webforms! 18‘27124, 10:26 How to Crete Crystal Reports In ASPINET Webforms
1. Create ASP.NET Web Forms Project
2. Create a Dataset
Dataset Designer
Choose your data connection wizard
Add Connection dialogue box
Choose your data connection wizard
Choose your Command Type
Enter SQL Statement dialogue box
Choose methods to Generate
3. Add Crystal Report to the Project
Crystal Report Gallery
4, Bind the Dataset to Crystal Report and Add Fields
Add fields to Report
5. Create an ASP.NET Web Form
Add a button to our web form
6. Add a Crystal Viewer Control to Web Forms and Bind it to the Report
Bind Report to the Crystal Report Viewer
7. Run And View The Report
Notes
Source Code
Run Crystal Reports Under 64 Bit IIS.
Create the ASP.NET Web Forms Application
Creating the Crystal Reports involves the following steps
1. Create ASP.NET Web Forms Project
2. Create the Dataset
3. Add Crystal Report to the Project
4, Bind Dataset to the Crystal Report and Add Fields
-ntps:hww-toktutorlatshub.convrysta-reportsinowsto-create-crystal-repors-n-asp-not-webforms! 212827704, 10:28 How to Create Crystal Repors in ASPNET Webfors
5. Add a Web Form to the project
6. Add CrystalReportViewer control & Bind it to the Report
7. Run and Test the Report
1. Create ASP.NET Web Forms Project
te er ——
Sine citeton [© Cate eecty ertan
The First step is to create a Web form application.
Follow these steps to create a Web Forms Project
1. Launch Visual Studio.
2. From the File menu, click New Project.
3. From Templates ->Visual C#
4, Select Web
5. Select ASP.NET Web Application
6. Choose Name as CrWebApp
7. Click on OK
This will open the New ASP.NET Project Wizard.
-ntps:hww-toktutorlatshub.convrysta-reportsinowsto-create-crystal-repors-n-asp-not-webforms! 3128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
New ASP.NET Project
1. Select Empty Template
2. Click on Webforms
3. Click on OK
2. Create a Dataset
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms!
4128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
In the Previous Tutorial, we learnt how to use OLE DB (ADO) connection. For this
example let us choose ADO.NET Dataset. To use ADO.NET Dataset we need to create a
dataset in our project. To do that follow the following steps
1. Select your Project
2. Right Click
3. Go to Add New
Add New Item dialogue box appears. Here follow these steps
1. Select New Item
2. Select Data on left-hand side box
3. On the right-hand side select Dataset
4. Name the dataset as customer
5. Click on Add
This will bring Dataset Designer on your screen
Take a Sneak Peek at Our Latest
Recommendations Here
DiscoveryFeed
Dataset Designer
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 5128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Right-click and select Table Adapter.
Choose your data connection wizard
This will bring up Choose your data connection wizard. The drop-down will display the
already created connections. To Create a new connection, click on the New
Connection
Click on New Connection
Add Connection dialogue box
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 6128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Add Connection
The next dialogue box is Add Connection dialogue box. The first Option in this screen
is data source which, is as you can see is displayed as Microsoft SQL Server (SQL
Client). if you wish to change it to some other provider then, click on Change. That
will take you to the list of available Data Source Select the appropriate one for your
project and Click OK
Since we are connecting to the SQL server database let us choose to cancel
Follow these steps to set your database connection
1. In Server Name field enter name of your SQL Server Instance Name
2. Under authentication, you can either choose windows authentication or
specify user ID & Password. | will choose Windows Authentication
3. Select database Name. Select NorthWind
4. Click on Test Connection to verify Connection
5. Click on OK to finish
We are taken back to the Choose your data Connection window
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! m8.ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Choose your data connection wizard
Connection Added
The new connection which we created in the previous step appears on drop down.
Expand the plus right below connection drop-down see the connection string
1, Select the Newly created connection
2. Click on NEXT
Save the connection
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 8128tania, 10:28 How to Create Crystal Reports in ASPNET Webforms
You will be prompted to whether you wish to add this connection to the web.config
file. Select yes and click Next. This will bring up Choose your Command Type Dialog
Box
Choose your Command Type
Here you are given three options to select the Command Type
Get More Out of Your Browsing Experience
With our Custom Content
DiscoveryFeed
1, Use SQL Statement
2. New Stored Procedure
3. Existing Stores Procedure
Let us choose Use SQL Statement. Click on Next. This will bring up Enter SQL
Statement dialogue box
Enter SQL Statement dialogue box
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 9128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Enter an SQL Statement
Here you are prompted for the SQL statement. Enter our query as
1
2 Select * from customers
3
Click on Next. This will take us to the Choose methods to Generate dialogue box
Choose methods to Generate
This wizard asks for the methods you want to add to our TableAdapter. Select tick on
all three and Click on Next. The dataset is generated for us. Save and close the dataset
Now we have created our dataset. We are now ready to connect this dataset to our
crystal report
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 0128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
3. Add Crystal Report to the Project
Add Crystal Report
To Add Crystal Reports to the Report do the following
1. Select your Project
2. Click Add
3. Click New Item
4. On the left-hand templates column, choose Reporting
5, Select Crystal Reports
6. Name the Report as rptCustomerList
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 108ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
7. Click on Add
This will bring up the Crystal Report Gallery
Crystal Report Gallery
Crystal Report Wizard
The Gallery offers three options to create report
1. Using The Report Wizard
2. Asa Blank Report
3. From an existing Report
In the Create your first Crystal Report Using Windows Forms, we showed you how to
create the report using the first Option i.e. using the Report wizard. For this example
let us create the report as a Blank Report
Select as blank Report and click on Ok
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! ra78tare, 1028, ow o Cresta Cyl Reports inASPNET Webform
Ablank Report is Created and ready for use. Notice that the reference to the following
Crystal Report Namespace is added to our project,
Get Ready For More Personalised
Recommendations Here
DiscoveryFeed
Reference Added
1. CrystalDecisions.CrystalReports.Engine
2. CrystalDecisions.ReportSource
3. CrystalDecisions.Shared
4. Bind the Dataset to Crystal Report and Add Fields
-ntps:hww-toktutorlatshub.convrysta-reportsinowsto-create-crystal-repors-n-asp-not-webforms! 13128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Database Expert
Now we need to connect this report to the dataset we created. Locate and Open the
crystal Report rptCustomerList. To Connect to the dataset do the following
1. Select Field Explorer
2.On Database fields > Right Click
3. Click on Database Expert
4, Go to Project Data and select ADO.NET Datasets
The dataset we have created will appear in the Project Data
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms!
4128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Attach Dataset
1. Select Customers Dataset.
2. Click on Right Arrow to add this to the Report.
3. Click on OK.
Add fields to Report
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 19128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Add Fields to the Report
The next step is to add the fields to the report. To do this follow these steps
1. Go to Fields Explorer.
You will notice that the customer table which has added here appears here
with all the fields.
2. Expand database fields.
3. Expand customers.
4, Select the fields you wish to place on Report Drag them to the report.
5. Let us Place title, companyName, contactName, contactTitle, and city in the
report.
Save the report and close all the open windows.
5. Create an ASP.NET Web Form
Create a Web Form
The next step is to create a web form to show the report. To do this follow these steps
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 16128tania, 10:28 How to Create Crystal Reports in ASPNET Webforms
1. Go to Project Right-click
2. Click on Add
3. Click on New Item
4, Add New Wizard Appears
5, Select Web
6. Select Webform
7. Name it as default.aspx
Click on add to create the form
Add a button to our web form
Add a Button
The next step is to add a button to our web form. To do this
1. Open the default.aspx.
2. Click on Design tab at the bottom.
3. Go to the toolbox.
4. Select button.
5. Drag it and place it on the web page.
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 128tare, 1028, son Create Crystal Reports nASPNET Webtoms
6, Rename the button caption as SHOW.
7. Rename the ID Property to Show.
6. Add a Crystal Viewer Control to Web Forms and
Bind it to the Report
Add a Crystal Report Viewer Control
The next step is to add crystal Viewer control to our form. To do this
1. Open the default.aspx.
2. Click on Design tab at the bottom.
3. Go to the toolbox.
4. Locate Reporting Tab.
5. Select Crystal Report Viewer Control.
6. Drag it on the web page.
Bind Report to the Crystal Report Viewer
To View the Crystal Report we need to bind the Report (rptCustomer) to the Crystal
Viewer Control, which we added to our Web Form. To do this double click on Show
Button to open the code behind class
We need to Import following Name Space from the Crystal Reports.
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 8128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Check Out Our Recommendations Curated
Just for You
DiscoveryFeed
1
2. Using CrystalDecisions.CrystalReports.Engine;
3. Using CrystalDecisions.Shared;
4
First, We need to Fill the data table with the Customers data. To do that Create an
instance of Table Adapter CustomersTableAdapter and invoke the Fill Method to Fill
the data.
Create the rpt object, which is an instance of our rptCustomerList. Note the
rptCustomerList is the name of the Crystal Report, which we had created in step 3.
Assigning the Dataset ds to Report using the method SetDataSource. The object rpt is
our Report.
Crystal Report Viewer control's job is to display the report. All we need to do is to
assign the report to the ReportSource Property of the Crystal Report Viewer Control
(CrystalReportViewer. ReportSource = rpt). Now our Crystal Report Viewer is ready to
display our report.
Finally, store our Report in the Session using Session.Add(“report”, rpt). The Report
object is retrieved from the Session and assigned to the ReportSource Property of the
CrystalReportViewer Control when the page is refreshed or user navigates from one
page to another. This is done from the Page_Init event.
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 19128217124, 10:28 How to Create Crystal Reports in ASP.NET Webforms
Finally, our code looks like this
1
2 using System;
3. using System.Collections.Generic;
4 using System.Ling;
5 using System.Web;
6 using System.Web.UI;
7 using System.Web.UI.WebControls; //Crystal Report Namespaces
8 using CrystalDecisions.CrystalReports.Engine;
9 usit
1g CrystalDecisions.Shared;
11 namespace CrWebFormsApp {
12. public partial class Default : System.Web.UIL.Page {
13 rptCustomerList rpt;
14
15 protected void Page_Load(object sender, EventArgs e){
16}
7
18 protected void Page_init(object sender, EventArgs e){
19
20 if (Session{"report"] != null)
2a
22 CrystalReportViewer1.ReportSource =(rptCustomerList)Session["report"];
230«+}
24}
25
26 protected void Show _Click(object sender, EventArgs e)<
27
28 CustomerTableAdapters.CustomersTableAdapter da = new CustomerTableAdapters.Ci
29 Customer ds = new Customer();
30 Customer.CustomersDataTable dt=(Customer.CustomersDataTable)
31 ds.Tables["Customers"];
32 da.Fill(dt);
33 rpt = new rptCustomerList();
34 rpt.SetDataSource(ds);
35 CrystalReportViewer1.ReportSource = rpt;
36 Session.Add(""report", rpt);
37}
38 )
39
7. Run And View The Report
-ntps:hww-toktutorlatshub.convrysta-reportsinowsto-create-crystal-repors-n-asp-not-webforms!
20128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Save and run and you will see your first report in ASP.NET Web Forms
Save And Run the Report
Notes
It may happen that report might not display properly or may not display at all. There
are two common problems, that usually occurs in ASP.NET Web Forms application.
1. Crystal report Errors : Could not load file or assembly crdb_adoplus or one of
its dependencies
2. Crystal Report Shows a blank Page in ASP.NET Web Application
Source Code
You can download the source code from the GitHub. The Source code is made using
Visual Studio 2015 Community Edition and SAP Crystal Reports Developer Edition for
Visual Studio Service Pack 17
The sample database Northwind can found from CodePlex
Run Crystal Reports Under 64 Bit IIS.
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 21128ram, 10:26 How to Create Crystal Reports in ASPNET Webforms
Go to Tools -> Option then select Project and Solutions -> Web Projects and tick on the
option “Use the 64-bit version of IIS Express for web sites and projects”
< Create Crystal Reports ASP.NET
Create Crystal Reports Visual ve
Studio >
Related Posts
How to Create Crystal Report Crystal Report Shows a blank
using Visual Studio Page in ASP.NET Web
Application
15 Comments / Crystal Reports / By TekTutorialsHub
8 Comments Crystal Reports / By TekTutorialsHub
12 thoughts on “How to Create Crystal Reports in ASP.NET
Webforms”
‘SRI THARANYA GOPALAKRISHNAN
APRIL 23, 2024 AT 12:07 PM
tps: www tktutorialshub. comierystalreportsMow-to-create-crystarepors-n-asp.net-webforms! 22128ramm, 10:26 How to Create Crystal Reports in ASPNET Webforms
HI, |‘m having a crystal report along with sub report .|s it possible to create web form
using the above method?
Ifso kindly help me with the same.
Thanks in advance..
Reply
RAE
NOVEMBER 17, 2022 AT 6:17 PM
Great tutorial! My pitfall: make sure the button is actually hooked up to the
Show_Click method before trying the fixes mentioned. When | was binding the data,
double clicking the “Show” button to access the code behind did not automatically set
that function as the button’s onclick. I had to go into the button’s html tag (you could
also set it in the button’s properties) and set it manually. Never rule out the simple
stuff l guess
Reply
‘SAMIULLAH
FEBRUARY 15, 2022 AT 10:23 AM
thanks so useful inform.. be strong
tps ww tktutorialshub.comierystalreportsMow-o-create-crystalrepors-n-asp.net-webforms! 23128ramm, 10:26 How to Create Crystal Reports in ASPNET Webforms
Reply
KATIMBO ALLAN
JANUARY 26, 2022 AT 3:12 PM
Thank you for example
| have a big problem crystals. | have designed an app using web forms in VS 2015.
When testing, the reports run well, but | deploy on the server, i get Load report failed.
How can this be resolved?
Thank you
[email protected]
Reply
SHAWN
DECEMBER 17, 2020 AT 2:25 AM
Can reports created with crystal reports 2020 be run on Windows 2019 server under
asp.net 4 or higher? If so what crystal runtime file needs to be installed on the server
and where do we download that file or app?
Reply
JOHN
tps www tktutoralshub.comierystalreportsMow-o-create-cystarepors-n-asp.net-webforms! 24128217124, 10:28 How to Create Crystal Reports in ASP.NET Webforms
MARCH 7, 2023 AT 7:37 PM
yes
OSCAR FIBLAS ARAMAYO
FEBRUARY 26, 2019 AT 6:22 AM
No hay como ese amistoso lenguaje Visual Basic .Net
MARIO
FEBRUARY 22, 2021 AT 9:37 PM
Totalmente de acuerdo
WENDY
SEPTEMBER 5, 2018 AT 11:56 PM
-ntps:ihww-tektutorlalshub.convrysta-reportsinowto-crate-crystal-repors-n-asp-not-webforms!
Reply
Reply
Reply
25128sane, 10:28 How to Create Crystal Reports in ASPNET Webforms
Hi
What if you don’t see the tables in the Database Expert window?
| don’t see mine appearing in the dataset. It was working before when | first tried.
Reply
VWAYLAKSHMI
DECEMBER 22, 2017 AT 3:15 PM
Crystal report generation using asp.net web forms is not working for me..
iam using VS 2015
there are no errors at all but the report isnt getting displayed on the browser
Reply
ANONYMOUS
JANUARY 22, 2021 AT 12:27 PM
You should import the crystal report 13 template in your current project and add
the reference config section in “web.config”
Reply
KATHERINE PAYNE CARDULLO
JUNE 22, 2017 AT 2:35 AM
tps ww tktutoralshub. comierystalreportsMow-to-create-crystarepors-n-asp.net-webforms! 26128ramm, 10:26 How to Create Crystal Reports in ASPNET Webforms
Excellent tutorial! This has helped me start an upgrade from Classic ASP and Crystal 8
running on a 32 bit app server to the latest Crystal in .net 2015 running on a 64 bit
server.
Reply
Leave a Comment
Your email address will not be published. Required fields are marked *
Type here..
Name*
Email*
tps www tktutoralshub.comierystalreportsMow-to-create-cystarepors-n-asp.net-webforms! 27128217124, 10:28 How to Create Crystal Reports in ASP.NET Webforms
Website
Post Comment
This site uses Akismet to reduce spam. Learn how your comment data is processed.
‘ad (0:03)
Copyright © 2024 TekTutorialsHub |
-ntps:hww-toktutorlatshub.convrysta-reportsinowsto-create-crystal-repors-n-asp-not-webforms! 28128