How to use crystal report with MYSQL Database connection in c#

A well-liked reporting tool called Crystal Reports enables programmers to design and create unique reports. Using a variety of data sources, including MYSQL databases, it offers developers a robust collection of features and tools that let them produce dynamic reports. You may utilize Crystal Reports with a MYSQL database connection in C# by following the instructions in this article.

1.Install Crystal Reports Runtime first.

The Crystal Reports runtime must be installed on your development machine before you can use Crystal Reports in your C# application. The SAP website offers a runtime installer for download.

2. Establish a MYSQL database

The next step is to build a MySQL database and add example data to it. Your database can be created and managed using the MySQL Workbench tool. You can begin developing your Crystal Reports once your database has been built.

3: start a new project

Create a new C# Windows Forms Application project by launching Visual Studio. A Crystal Reports viewer control can be added to your form once your project has been built.

Step 4: Access the MySQL database

Installing the MYSQL connector for.NET is required to establish a connection to the MySQL database. From the MYSQL website, you can download the connector.

Change your password and your database to the password and database name for your MySQL server.

Build a new Crystal Report in step five.

You can begin building your Crystal Reports once you have created a connection to your MYSQL database. Right-click on your project in the Solution Explorer and choose Add > New Item to accomplish this. Click Add after choosing Crystal Reports from the list of possible templates.

Click OK after choosing the Blank Report template in the Crystal Reports Gallery. Choose the tables and fields you wish to include in your report in the Database Expert by choosing the MySQL connection you created previously.

Step 6.is to bind the Crystal Report Viewer Control.

The code below should be added to your form in order to link the Crystal Reports viewer control to your report: The path to your Crystal Report file should be substituted for path to your report file.rpt.

Step 7: show the report

> Add the next code to your form to display the report in the Crystal Reports reader control:

Step 8: Launch the Program

To view your Crystal Report in action, run your application at this point. The Crystal Reports viewer control will display your report based on the data from your MYSQL database when you execute your application.

To sum up, Crystal Reports is an effective reporting tool that works with a range of data sources, including MYSQL databases. By using a MYSQL database connection and the instructions in this tutorial, you may quickly produce and show Crystal Reports in your C# program.

Discussions

Post a Comment