The paid versions of Visual Studio include an add-in called Report Builder which lets you create reports from a dataset in design mode. Using Report Builder results in the creation of a file similar to Report1.rdlc, which is a Client Definition file. You then use the ReportViewer control from the toolbox to show this report in one of your forms.

In Visual Studio Express, you do not have the Report Builder utility, nor do you immediately have the ReportViewer in your toolbox. However, with a little setup time you can use Report Builder just as easily.

Report Builder is actually a component of SQL Server. If you are using SQL Server 2012 Express, make sure you have selected all of the reporting features that are offered during installation, or you can go back and add them to your instance by running the same setup file again.

SQL Server Express does not include Report Builder, but it is a free download on Microsoft’s website:
http://www.microsoft.com/en-us/downl....aspx?id=35576

After installing the Report Builder, you need to install the 2012 Report Viewer Runtime, which is also a free download on Microsoft’s website:
http://www.microsoft.com/en-us/downl....aspx?id=35747

Once both are installed, open Visual Studio 2012 Express and go to Tools > Choose Toolbox Items.

Name:  viewer1.png
Views: 111532
Size:  19.7 KB


If you scroll through the list on the .NET tab you will find two ReportViewer controls, one for WebForms and the other for WinForms. Both of those are version 10.0.0.0, which ships with VS 2012. We actually want the new version that we installed, which is version 11.0.0.0. You can find it by clicking on the browse button.

Name:  viewer2.png
Views: 115069
Size:  61.8 KB


Navigate to the ReportViewer Runtime that you installed and select Microsoft.ReportViewer.WinForms.dll.

Name:  viewer3.png
Views: 111588
Size:  113.1 KB


Now you will find the Report Viewer control in your toolbox.

Name:  viewer4.png
Views: 106485
Size:  10.9 KB


Now, I’m not going to go through the entire process of showing you how to use Report Builder. You can find a great example here:
http://msdn.microsoft.com/en-us/library/ff519552.aspx

What you should know, is that Report Builder will create a file like Report1.rdl. Notice that this file does not end with .rdlc like the one that is created using the Report Builder add-in for Visual Studio!
Simply add the “c” to the end of the extension and you can now access the file using the Report Viewer control.

A few hints. When you supply your report with a datatable in code, it will need to have the same name as the dataset you created in Report Builder.

Here is an example of filling a datatable and then showing a report:

vb.net Code:
  1. Imports Microsoft.Reporting.WinForms


This code assumes you know how to fill a datatable:

vb.net Code:
  1. Me.BindingSource1.DataSource = MyDataTable
  2. Dim rds As New ReportDataSource("DataSet1", Me.BindingSource1)
  3.  
  4. Me.ReportViewer1.LocalReport.ReportPath = "C:\SalesReport1.rdlc"
  5. Me.ReportViewer1.LocalReport.DataSources.Clear()
  6. Me.ReportViewer1.LocalReport.DataSources.Add(rds)
  7. Me.ReportViewer1.RefreshReport()