We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 19
rama, 10:27 Crystal Reports in ASP.NET MVC and ADO.NET Entty Model
Crystal Reports in ASP.NET MVC and
ADO.NET Entity Model
‘5 Comments /4 minutes of reading / February 13, 2020
< Export Formats —>
Crystal Reports in WebForms
In this tutorial, we are going to look at how to create Crystal Reports in ASP.NET MVC
using ADO.NET Entity model. ADO.NET entity model is an ORM framework. In our last
tutorials, we explained how to create the Crystal Report using Windows desktop
application and ASP.NET Webforms. Please read these tutorials from the following
links.
1. Create Crystal Report using Windows Desktop Application
2. Create Crystal Report using ASP.NET Webforms
In this tutorials, we are going to
1. Create an empty MVC Project.
2. Create a data connection.
3. Create an entity Data Object.
4. Create a report.
5. Bind the report to an entity model.
6. Run the report.
Table of Contents
bitpshwwtktutorialshub.comierystal-reportsiereate-New->Project.
3. Select Visual C# -> Web > ASP.NET Application.
4, Name the Project as crMVCApp.
5. Click on OK.
-ntps:hwww- toktutorlalshab.comverysta-repots/create-crystal-eport.n-asp-netanvel anerama, 10:27 Crystal Reports in ASP.NET MVC and ADO.NET Entty Model
This will bring up the New ASP.NET Project template.
An emety oft tebe ceatng ASP NET opts.
7 + ‘Tastempte does ot have any conan
Si Od
wc webart Lexnmare
e) = 6
SaplePage foe Mle
fopcaton— Servee
ange Auterteatin
tentcaton: Wo Authentication
ek ober and xpos ‘58 mirosote Azure
T web rormg” Five) webaet > Fist tecoud
Prat nt tk state z
Test project rae
Select Empty and then MVC
1, Select Empty.
2. Select MVC.
3. Click on OK.
The MVC Project is created. Run and verify whether the application is working
correctly.
Create a Data Connection
Next step is to Create a data Connection to our Project. To Do this follow, these steps.
bitpsihwotktutorialshub.comierystal-reportslereate-View -> Server Explorer.
2. Select Data Connection.
3. Right, Click on add connection.
This will open Choose Data source dialog box.
bitpsihwotktutorialshub.comierystal-reportslereate- Add New.
This will bring up the Add New Item dialog box.
Create ADO.NET Entity Model
1. Select data.
2. Select ADO.NET Entity Data Model.
3. Enter the name of the model as Customer.
4. Click on Add.
5, This will take you to Entity Data model wizard.
bitpsihwotktutorialshub.comierystal-reportslereate-Add New.
4, Select Reporting.
5, Select Crystal Reports.
6. Enter the name of the report as CustomerList.rpt.
7. Click on Add.
This will bring up the Crystal Report Gallery.
8. Select As a Blank Report.
9. Click on OK.
These steps are explained in the tutorial Create Report Using ASP.NET
Webforms.
This will create a blank report.
10. Select Field Explorer.
11. Right Click and select Database Expert.
bitpsihwotktutorialshub.comierystal-reportslereate-Show Customer List
Now go to HomeController . and add the Import the following namespaces.
using System.10;
using CrMVCApp.Models;
RUNE
Create a new Action method ShowCustomerList with the following code.
public ActionResult ShowCustomerList()
{
CrMVCApp.Models. NORTHWINDEntities db = new crMVCApp.Models. NORTHWINDEntitie:
//CrMVCApp.Models.Customer ¢
var c = (from b in db.Customers select b).ToList();
eVausune
CustomerList rpt = new CustomerList();
9 rpt.Load();
10 rpt.SetDataSource(c);
11 Stream s = rpt.ExportToStream(CrystalDecisions. Shared.ExportFormatType.PortableDoct
12 return File( s,"application/pdt);
13}
14
Run the Report
bitpsihwotktutorialshub.comierystal-reportslereate-
Crystal Reports in WebForms
Related Posts
How to Create Crystal Report How to Create Crystal Reports
using Visual Studio in ASP.NET Webforms
15 Comments / Crystal Reports / By TekTutorialsHub 12. Comments / Crystal Reports / By TekTutorialsHub
bitpsihwotktutorialshub.comierystal-reportslereate-