Last Updated on November 10, 2022 by Humera hallari
Creating reports with crystal reports in Visual Studio will be able to simplify and shorten the work of displaying reports. This is because crystal reports provide a ready-made and ready-to-use view of reports.
To create a report in Visual Basic using Crystal Reports is quite easy. Mainly if using MySQL. All you need is a MySQL Connector, Xampp, Crystal Reports, and datasets. In addition to datasets you need to install it first, because the dataset is included in Visual Studio.
You can download the project as well as the source code below.
Imports mysql.data.MySqlClient Public Class Form1 Dim con1 As MySqlConnection Dim cmd1 As MySqlCommand Dim adp1 As MySqlDataAdapter Dim dtb As New DataTable Sub viewdata() cmd1 = New MySqlCommand("select * from detailreport", con1) adp1 = New MySqlDataAdapter(cmd1) adp1.Fill(dtb) con1.Close() con1.Dispose() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click dtb.Clear() con1 = New MySqlConnection("server=localhost;user=root;password='';database=dbvb") Dim myrpt As New myreport viewdata() myrpt.Database.Tables("detailreport").SetDataSource(dtb) CrystalReportViewer1.ReportSource = Nothing CrystalReportViewer1.ReportSource = myrpt End Sub End Class
You need at least Visual Studio 2019 to open this project. For those of you who need, you can download the crystal reports basic report project through the following link.
IDE: Visual Studio 2019
Extensions: MySQL Connector
Database Server: MySQL on XAMPP
Report: Crystal Reports