Last Updated on August 21, 2023 by Humera Hallari
The following is the source code of the project how to create a Crystal Reports report using two or more database tables. With this method we will be able to display the contents of several tables into one Crystal Reports page.
With this method we no longer need to make many reports for each table. However, it should be noted that creating a report with a multi table must pay attention to the database column. Because when we display data we need a relationship between tables that can only be done if each table has one or more columns of the same type.
Here you can download the project and also the source code of how to display reports with multitables using Crystal Reports and VB.NET.
You can modify the code freely as per your needs. Projects can be opened with Visual Studio 2019. For more details it is recommended to watch the guide video from part 1 about this Crystal Report.
Source Code
Imports MySql.Data.MySqlClient
Public Class Form2
Dim con1 As MySqlConnection
Dim cmd1 As MySqlCommand
Dim adp1 As MySqlDataAdapter
Dim dtb As New DataTable
Dim dtbsub As New DataTable
Sub viewdata()
cmd1 = New MySqlCommand("select * from detailreport", con1)
adp1 = New MySqlDataAdapter(cmd1)
adp1.Fill(dtb)
cmd1 = New MySqlCommand("select * from subreport", con1)
adp1 = New MySqlDataAdapter(cmd1)
adp1.Fill(dtbsub)
con1.Close()
con1.Dispose()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
dtb.Clear()
dtbsub.Clear()
con1 = New MySqlConnection("server=localhost;user=root;password='';database=dbvb")
Dim myrpt As New multireport
viewdata()
myrpt.Database.Tables("detailreport").SetDataSource(dtb)
myrpt.Database.Tables("subreport").SetDataSource(dtbsub)
CrystalReportViewer1.ReportSource = Nothing
CrystalReportViewer1.ReportSource = myrpt
End Sub
Project Download
Requirements:
Visual Studio 2019
Crystal Reports
MySQL Connector
Xampp with Database
Developer: Nosware
Website: https://www.nosware.com
Read more about Basic Reports VB.NET & Crystal Reports Source Code [Project]
I am sorry for my spilling the last comment .
can we use that for free?
Yes you can. Thank you