How to create crystal reports with asp.net mvc

create crystal reports with asp.net mvc

Using software solutions to streamline businesses intelligence and productivity have been sought-after for many years. The primary purpose is to get deeper insights into business information and position an organization for a more significant competitive advantage. In short, advance web reporting. That being said, crystal reports have been around for many years for small and medium-sized organizations globally. So how to create crystal reports with asp.net mvc is a query we have been receiving a lot.

So, let’s check out:

What are crystal reports?

Crystal reports is a report generation software for creating custom reports from any variety of data sources. It is a windows-based solution with which the developers perpetuate the advanced web reporting. That is, creating the reports and dashboards (with a minimum of code to write) from a range of data sources.

To put it simply:

Crystal reports – a business intelligence application that helps businesses analyze their data by creating format-rich, pixel-perfect and multi-page reports. You can view, update, and share the reports inside a web browser.

Whichever business reports and data individuals mostly have to access, they prefer them in a format easy to:

  • View
  • Export
  • Print

With crystal reports, too, you can have the same course of action. After creating the reports, make use of the crystalreportviewer asp.net, a customized solution. It is more like a print preview of your generated reports and allows you and your employees to view them in windows and web applications. On top of all, you can manage, run, refresh, export, print, and email the reports.

That was a brief intro to crystal reports. Now let’s get back to the central focus:

How to create crystal reports with asp.net mvc?

Remember, there are many approaches to create crystal reports. Even in asp.net, too, you have various methods. In this post, we will spotlight the asp.net mvc while using the ADO.NET Entity Model.

P.S. ASP.NET – a web platform that creates a layer to facilitate the creation of web applications and web services. At the same time, asp.net mvc is a framework to build web applications. Asp.net mvc sits on top of asp.net and uses asp.net provided APIs.

  1. Start with an Empty ASP.NET MVC Application

To start with, you need to create an empty mvc application – a new mvc project and to do so:

  • Go to Visual Studio.
  • Click on File and then New Project.
  • From the Templates tab, click on Visual C# and then Web
  • From the three option appeared you have to select the NET Application.
  • Next, you have to name this new Project. So name it as crMVCApp.
  • Click on OK to open the asp.net project template.
  • On opening the template window, select Empty and tick-mark the MVC
  • Finally, press OK to finish the mvc project (application) creation.

Now move on to the second step.

  1. Create a Data Connection 

To establish a data Connection for the Project, the following is the step by step mechanism.

  • Go to Menu and then View and Select Server Explorer.
  • Next, right-click on Data Connection and click on Add Connection.
  • On clicking, it will open a dialogue box Choose Data source.
  • Now, for “data source”, select Microsoft SQL Server.
  • For “data provider”, select .NET Framework Data Provider for SQL Server.
  • Press Continue.

Then you will see a new small window with the name “Add Connection.”

  • Enter the “server name”.
  • Mark the Windows Authentication.
  • In “Connect to a database”, from the Drop-down menu, select NORTHWIND.
  • Finally, click OK.

Next, we are moving on to the ADO.NET model. Thus,

  1. Build ADO.NET Entity Data Model
  • Go to the project folder and select the Models
  • Right-click and select Add and Add New.
  •  Then you will see the window “Add New Item”.
  • Here, click on Data and select NET Entity Data Model.
  • In the bar below, you have to enter the name of the model. For instance, say “Customer” and press Add.

Eventually, an Entity Data model wizard will pop up. Now,

  • Choose E.F. Designer from database and press Next.
  • This will take you to “Choose your Data Connection”.

Remember, we have already established the data connection. In the drop-down menu, you can see it there, so

  • Pick your connection.
  • Checkmark the Save connection settings in Web.config as.
  • Enter the name of the connection as NorthwindEntities and press Next.
  • If “Version of the framework” pops up to let you choose. Select the latest, and press Next.

Afterwards, you will be directed to “Choose your database Objects and Settings”.

  • You will see a list, tick mark the Customers and write the NORTHWINDModel as the Model Namespace.
  • Press Finish.

Until now, you have completed the creation NORTHWINDModel ADO.NET entity model.

The previous three steps are to set up the background to crystal reports with asp.net mvc. From here on, we will jump to crystal reports.

  1. Create a Crystal Report
  • Select your Project and build it. (It will update the reference to the ADO.NET entity model in Database expert in crystal reports.)
  • Right-Click the project folder > Add > Add New.
  • Choose Reporting and select Crystal Reports.
  • Name of the report as rpt and click Add.

This procedure will display the Crystal Report Gallery.

  • Here, choose As a Blank Report and press OK. (it will create a blank report)
  • Right-click the Field Explorer and select Database Expert.
  • Here, select the Project Data > .NET Objects.
  • Select your created “entity model” Models.Customer and click the arrow (>) on the left and click OK.

Next, enter the data in the required Fields (of Fields Explorer) like I.D., name, title, address.

This is it with the process to crystal reports with asp.net mvc! Your report is ready.

If you want to show the report, use crystalreportviewer asp.net. However, it might not work, so you have to download the report. You can do it via the controller folder.

In case you face any error while creating the crystal reports, contact us with your queries and find an instant solution.

What are you waiting for?

Follow the above steps and leverage the crystal reports for your business. Employ crystalreportviewer asp.net. to open and view live data from these Crystal Reports.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button