Create an RDLC Data Report in VB.NET in 7 Steps

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- create an RDLC Data Report in VB.NET

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. 

  1. Imports System.Data
  2. Imports System.Data.OleDb
  3. 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

23 Comments

  1. Andre said:

    Thanks for your tutorial,
    But i got an error when i try show 2 dataset in one report.rdlc.

    May 4, 2020
    Reply
    • admin said:

      Hi Andre. One RDLC report can have only one dataset. If you need to create more than one datasets from different table for report, it will generate error. It will be better if you create an SQL statement with Joins to get data from required tables and associate this query with dataset and fetch data from multiple tables.

      May 4, 2020
      Reply
  2. Okta said:

    Thank you very much for your tutorial, very big help because it’s difficult to find this information and finally it works ..yeayy..

    July 25, 2020
    Reply
  3. Asa Kolmer said:

    Hello! I just wish to give a huge thumbs up for the great info you could have right here on this post. I will be coming back to your blog for extra soon.

    August 18, 2020
    Reply
  4. Leesa said:

    Appreciate this post. Will try it out.

    September 15, 2020
    Reply
  5. There’s certainly a great deal to learn about this
    issue. I love all of the points you have made.

    September 16, 2020
    Reply
  6. Hi there, yup this piece of writing is in fact nice and I have learned lot
    of things from it on the topic of blogging. thanks.

    September 21, 2020
    Reply
  7. php video cms said:

    I must thank you for the efforts you have put in writing this website.

    I’m hoping to see the same high-grade content by you later on as well.
    In fact, your creative writing abilities has encouraged me
    to get my very own website now 😉

    September 29, 2020
    Reply
  8. Anonymous said:

    Thanks for finally talking about > Create an RDLC Data Report in VB.NET
    in 7 Steps – CSVeda < Loved it!

    October 1, 2020
    Reply
  9. Myrtle said:

    Hey there! I’ve been reading your web site for some time now and finally got
    the courage to go ahead and give you a shout out from Humble Tx!

    Just wanted to mention keep up the excellent job!

    October 7, 2020
    Reply
  10. Technologyweekblog.Us said:

    Thanks very nice blog!

    October 18, 2020
    Reply
  11. Ellie said:

    I could not refrain from commenting. Exceptionally well written!

    October 20, 2020
    Reply
  12. Karolin said:

    Highly descriptive article, I liked that a lot. Will there be a part 2?

    October 21, 2020
    Reply
  13. Eş seçiminde Aile Baskısı said:

    Keep on working, great job!

    October 27, 2020
    Reply
  14. ฉีดปลวกเชียงใหม่ said:

    This site was… how do you say it? Relevant!! Finally I’ve
    found something that helped me. Thank you!

    October 28, 2020
    Reply
  15. Keluaran SGP said:

    It’s really a nice and helpful piece of information. I am satisfied that you just shared
    this useful information with us. Please keep us informed like this.
    Thanks for sharing.

    October 28, 2020
    Reply
  16. Lorenzo said:

    Hi there, just wanted to mention, I enjoyed this article.
    It was funny. Keep on posting!

    October 28, 2020
    Reply
  17. Ulysses said:

    I do accept as true with all the concepts you have introduced in your post.
    They’re really convincing and can certainly work. Still, the posts are very brief for newbies.
    May you please lengthen them a little from subsequent time?
    Thanks for the post.

    October 30, 2020
    Reply
    • admin said:

      Thanks for your suggestion. We will definitely keep this in mind.

      October 30, 2020
      Reply
  18. BandarQ said:

    Keep on writing, great job!

    November 23, 2020
    Reply
  19. Agen338 said:

    Major thanks for the article. Cool.

    December 11, 2021
    Reply

Leave a Reply

Your email address will not be published.