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.
In the above dialog box
- Under “Common Item” select “Data”
- from the adjoining pane, select “Dataset”
- Change the name of the dataset in the “Name” textbox. I have given it the name “LabTestDS.xsd”.
- Now click “Add” button to add this dataset in your project
This new Dataset will appear in the solution explorer.
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
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
Step-4 Add RDLC Report to Project
Again go back to “Project” menu and click “Add New Item”
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.
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
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.
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.
On right top of the ReportViewer you can see a small arrow as shown in the following image.
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.)
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
Thanks for your tutorial,
But i got an error when i try show 2 dataset in one report.rdlc.
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.
Thank you very much for your tutorial, very big help because it’s difficult to find this information and finally it works ..yeayy..
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.
Appreciate this post. Will try it out.
There’s certainly a great deal to learn about this
issue. I love all of the points you have made.
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.
Hello, I enjoy reading through your article. I like to write a little comment
to support you.
Fine way of telling, and nice article to obtain information on the topic of my
presentation subject, which i am going to deliver in college.
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 😉
Thanks for finally talking about > Create an RDLC Data Report in VB.NET
in 7 Steps – CSVeda < Loved it!
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!
Thanks very nice blog!
I could not refrain from commenting. Exceptionally well written!
Highly descriptive article, I liked that a lot. Will there be a part 2?
Keep on working, great job!
This site was… how do you say it? Relevant!! Finally I’ve
found something that helped me. Thank you!
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.
Hi there, just wanted to mention, I enjoyed this article.
It was funny. Keep on posting!
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.
Thanks for your suggestion. We will definitely keep this in mind.
Keep on writing, great job!
Major thanks for the article. Cool.