A data report is an essential element in database projects. The reports can be viewed or printed. We will understand here how to create an RDLC Data Report in VB.NET. for any queries about RDLC you can refer here.  Let’s start with the steps.

Step-1 Create Dataset

In “Project” menu select option “Add New Item” option and you will get this Dialog box.

AddNewItemDataSet

In the above dialog box

  1. Under “Common Item” select “Data”
  2. from the adjoining pane, select “Dataset”
  3. Change the name of the dataset in the “Name” textbox. I have given it the name “LabTestDS.xsd”.
  4. Now click “Add” button to add this dataset in your project

This new Dataset will appear in the solution explorer.

dataset in Solution Window

Step-2 Add Datatable

Now click the Dataset you just created. Here it is LabTestDS.xsd and in the toolbox open the DataSet collection to get the dataset objects that can be created.

Select DataTable option and you will get the following dialog box to add a DataTable in the newly created Dataset

DS data table

Step-3 Add Columns Needed for Report

Right click on the DataTable1 you will get a context menu. Click  the first option “Add” and Click “Column” option to add columns in this DataTable. Rename the DataTable after all the the columns are added

DS data table edited

Step-4 Add RDLC Report to Project

Again go back to “Project” menu and click “Add New Item”

AddNewItemrdlcReport

Select “Common Items” then under “Web” select “Reporting” and in the detailed pane on left select “Report” option.

Step-5 Design RDLC Report

You will get a blank RDLC report interface where you can add the columns you have just added in your DataTable.

rdlc report design interface

From the toolbox select the “List” option and draw a rectangle in the rdlc interface.

You will get this dialog box. Choose the Data Source and DataSet and click OK.

Now click  RDLC report tab and select the report data in the toolbox

rdlc report toolbox

Now add the columns from the Datasets->DataSet1 to the report . Design the report as per requirement by using “Report Toolbox” with the help of Report Controls very similar to WindowsForm controls.

design rdlc Report

The above picture is the final report I have designed. I used textbox for report header and lines to differentiate between records.

Step-6 Attach RDLC Report to Reportviewer in a form

Now that your report is ready, the last task is to attach report to a ReportViewer and launch it.

To do this open a new form to execute an present the report. Add a ReportViewer to it.

addreportviewer

On right top of the ReportViewer you can see a small arrow as shown in the following image.

rdlc report choose arrow

 

Click it and you will get the list of rdlc reports available in your project solution. Select the one you just created ( I didn’t change the name so the recent one I created was Report3.rdlc.)

choose rdlc report

Next you need to add the functionality for filling data and launching report in the form which contains the ReportViewer. I named this form as repPatientList. Open code window of this from and add this code

Step-7 Add Code in Form Load Event of Form Containing Reportviewer

Three lines of importing the packages must be added before the class.

 
 
Imports System.Data
Imports System.Data.OleDb
Imports Microsoft.Reporting.WinForms

 

This code goes in the Form Load event procedure

 
 
Public Class repPatientList
    Private Sub repPatientList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim dt As New DataTable
        connectdB()
        Dim cmd As New OleDb.OleDbCommand("SELECT * from PatientMaster", connDB)
        cmd.CommandTimeout = 4096
        Dim ta As New OleDb.OleDbDataAdapter(cmd)
        ta.Fill(dt)
        With Me.ReportViewer1.LocalReport
            .DataSources.Clear()
            .DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt))
        End With
        Me.ReportViewer1.RefreshReport()
    End Sub
End Class

 

You have completed all the steps of how to Create an RDLC Data Report in VB.NET. Now select the ReportViewer containing form in the project properties and run the project

final rdlc report