-
Apr 8th, 2013, 12:13 PM
#1
Thread Starter
Frenzied Member
How to use Report Viewer with Visual Studio 2012 Express
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.
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.
Navigate to the ReportViewer Runtime that you installed and select Microsoft.ReportViewer.WinForms.dll.
Now you will find the Report Viewer control in your toolbox.
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:
Imports Microsoft.Reporting.WinForms
This code assumes you know how to fill a datatable:
vb.net Code:
Me.BindingSource1.DataSource = MyDataTable
Dim rds As New ReportDataSource("DataSet1", Me.BindingSource1)
Me.ReportViewer1.LocalReport.ReportPath = "C:\SalesReport1.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(rds)
Me.ReportViewer1.RefreshReport()
-
Apr 10th, 2013, 07:58 AM
#2
Re: How to use Report Viewer with Visual Studio 2012 Express
Whats next? is there a way to print the report without a print preview etc?
and.. if i have built the report to have a parameter (@OrderID) how would i do that in vb? (or is that just part of the data source....? should the report NOT have the parameter and then just do the parameter on the datatable?)
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 10th, 2013, 11:24 AM
#3
Thread Starter
Frenzied Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Originally Posted by Static
Whats next? is there a way to print the report without a print preview etc?
I think you need to slow down and follow the process, paying careful attention to each part. The ReportViewer control has a print button, as well as export buttons.
Originally Posted by Static
and.. if i have built the report to have a parameter (@OrderID) how would i do that in vb? (or is that just part of the data source....? should the report NOT have the parameter and then just do the parameter on the datatable?)
If you use my example, you only have to make sure the datatable you supply to the report has the same columns. I try not to use parameters when creating the report, that way they are not expected.
-
Apr 11th, 2013, 05:55 PM
#4
Re: How to use Report Viewer with Visual Studio 2012 Express
ok then.. first things first.. my reportviewer control has NO controls? its doesnt show up on the form..it shows below (like if you add a timer)...?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 11th, 2013, 06:45 PM
#5
Thread Starter
Frenzied Member
Re: How to use Report Viewer with Visual Studio 2012 Express
You must have missed the steps where you install the 2012 ReportViewer Runtime and add the new version of the control to your toolbox. The behavior you described is what you will get when using Version 10.0.0.0, which is what ships with Visual Studio 2012 Express. You have to remove that control from your toolbox and add Version 11.0.0.0, which is what the Runtime installs.
-
Apr 14th, 2013, 08:15 AM
#6
Re: How to use Report Viewer with Visual Studio 2012 Express
you were correct.. although i had to just through hoops - both were installed (10,11) and it kept re-pointing to 10... took a few tries lol
thanks.
ok, next question. can you print right away without having to show anything?
Thanks!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 14th, 2013, 01:17 PM
#7
Thread Starter
Frenzied Member
Re: How to use Report Viewer with Visual Studio 2012 Express
The print and export functions are provided by the ReportViewer. However, there has to be a report rdlc loaded in order to print, even if it has no data to show.
-
Apr 15th, 2013, 08:14 AM
#8
Re: How to use Report Viewer with Visual Studio 2012 Express
AHA! Yes!! ok.. that is a pain!...
I have the Report Viewer working.. it opens, data loads, etc...
I know it has a print button etc, but i was hoping there was a way to have it autoprint?
i click a button.. the RV loads the report and shoots it right to the printer...
Nevermind! Got it!!
using this:
http://msdn.microsoft.com/en-us/library/ms252091.aspx
I added the class to my project, changed the data sources, tweaked the subs to allow me to pass in a value.. and BAM!!
Perfection!
Thanks!
Last edited by Static; Apr 15th, 2013 at 08:47 AM.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Oct 28th, 2013, 04:17 AM
#9
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Hi,
I have followed both the steps you had mentioned for downloading, but still that winforms.dll is not appearing when I browse that folder. Hence I reinstalled once again, but in vain. Could you please advice why I am not able to find it?
Regards,
Kiran
Originally Posted by circuits2
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.
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.
Navigate to the ReportViewer Runtime that you installed and select Microsoft.ReportViewer.WinForms.dll.
Now you will find the Report Viewer control in your toolbox.
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:
Imports Microsoft.Reporting.WinForms
This code assumes you know how to fill a datatable:
vb.net Code:
Me.BindingSource1.DataSource = MyDataTable
Dim rds As New ReportDataSource("DataSet1", Me.BindingSource1)
Me.ReportViewer1.LocalReport.ReportPath = "C:\SalesReport1.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(rds)
Me.ReportViewer1.RefreshReport()
-
Nov 5th, 2013, 09:42 PM
#10
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Hello,
I also followed the steps (twice) but I don't end up with this .dll file in the correct folder...
A
-
Nov 5th, 2013, 10:11 PM
#11
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
I should add - I don't even have a ReportBuilder folder in my Microsoft Visual Studio 11.0 folder.
I'm sure I didn't miss anything...
-
Dec 26th, 2013, 09:32 PM
#12
Thread Starter
Frenzied Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Originally Posted by amberHancock
I should add - I don't even have a ReportBuilder folder in my Microsoft Visual Studio 11.0 folder.
I'm sure I didn't miss anything...
The WinForms.dll is installed as part of the ReportViewer runtime, not the ReportBuilder. The install path may be slightly different on your system but a simple search will help you find it.
-
Jan 28th, 2014, 08:10 AM
#13
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
I just don't know what to do anymore. I have tried for over 6 hours to get this report viewer tool to show up in my toolbox. I have followed your instructions meticulously but the Report Viewer folder will not show in my Visual Studio 11.0 folder. I have searched for the dll file on my computer and cannot find it. I have found the Report Builder file under my SQL Server program folder, but Report Viewer folder is just not anywhere. What can I do to get this on my computer? or find it if it's already installed?
-
Jan 30th, 2014, 04:26 PM
#14
Fanatic Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Can someone write a good tutorial about using of Report Viewer related with programming? It is very hard to find any good resource about this control. I can't touch how to create a report using SQL statements.
-
Feb 1st, 2014, 05:37 PM
#15
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
I installed both the Report Builder and the Report Viewer Runtime as indicated above.
Installation was successful.
However, the runtime dll does NOT install to the folder.
I simply cannot find the Winforms.dll file. Even after searching the entire C: drive.
Anyone else have this problem?
Anyone have the answer to this?
I'm using visual studio 2012 express and sql server 2012 express.
thank you!
Jeff
-
Feb 15th, 2014, 10:08 PM
#16
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Can anyone explain more about how to add the data source? I have data table, which I'm able to use with a data grid view control, but I cannot manage to link it to the report viewer. My report appears, with the correct columns, but with no data in it. Here is what I have:
Code:
Me.MerchantsTableAdapter1.FillBy(Me.TestDataSet1.Merchants)
Me.BindingSource1.DataSource = Me.MerchantsTableAdapter1
Dim rds As New ReportDataSource("DataSet1", Me.BindingSource1)
-
May 5th, 2014, 04:31 AM
#17
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Originally Posted by jeff@databae.com
I installed both the Report Builder and the Report Viewer Runtime as indicated above.
Installation was successful.
However, the runtime dll does NOT install to the folder.
I simply cannot find the Winforms.dll file. Even after searching the entire C: drive.
Anyone else have this problem?
Anyone have the answer to this?
I'm using visual studio 2012 express and sql server 2012 express.
thank you!
Jeff
I'm using Windows8 and vb2013 express and installed ReportBuilder and ReportViewer as indicated above. NOTE: The Microsoft.Reporting.WinForms.dll 11.0.0.0 was installed in a subdir of C:\windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\11.0.0.0__…..
Only thing remaining: how to get it working! This is what I did:
1. I built a report in ReportBuilder3.0. I used an Access database (Contacts.mdb). In the mdb there is a table Prive containing names, adresses, phone numbers etc. The Datasource in ReportBuilder I named ContactsDataSet (like the name VB2013 gave to my Datasource). The DataSet in ReportBuilder I named "DataSet1". The report resulting from ReportBuilder I named prive.rdl.
2. Next I renamed the rdl file to prive.rdlc
3. In my Contacts project (VB2013 Express) I added a button to my Form1 (btnPrint; the Click event is just Form2.Show).
4. I added Form2 to my project, drag and dropped ReportViewer to Form2. The control appeared on the Form2 surface and I added the following code to Form2:
Imports Microsoft.Reporting.WinForms
Public Class Form2
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub ReportViewer1_Load(sender As Object, e As EventArgs) Handles ReportViewer1.Load
Dim cn As New OleDb.OleDbConnection
cn.ConnectionString = My.Settings.ContactsConnectionString
cn.Open()
Dim da As New OleDb.OleDbDataAdapter
Dim sql As New OleDb.OleDbCommand("select * from prive order by naam", cn)
Dim Prive As New DataTable
da.SelectCommand = sql
da.Fill(Prive)
Dim bs As New BindingSource
bs.DataSource = Prive
Try
Dim rds As New ReportDataSource("DataSet1", Prive)
Me.ReportViewer1.LocalReport.ReportPath = "D:\prive.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(rds)
Me.ReportViewer1.RefreshReport()
Catch ex As Exception
MsgBox(ex.Message)
End Try
cn.Close()
End Sub
End Class
4. When I click the print button on Form1 the report appears in Form2. It works!
5. Note: when you drag and drop the ReportViewer control the control should appear on the Form surface! If this does not happen try recreating your project from scratch; that's what I did when the ReportViewer control did not appear on my form. Possibly this has to do with the version of the ReportViewer control when you start your project; possibly changing versions in midstream is too confusing for VB ...
Last edited by Quint; May 16th, 2014 at 10:35 AM.
-
May 5th, 2014, 04:39 AM
#18
New Member
Re: How to use Report Viewer with Visual Studio 2012 Express
Originally Posted by jeff@databae.com
I installed both the Report Builder and the Report Viewer Runtime as indicated above.
Installation was successful.
However, the runtime dll does NOT install to the folder.
I simply cannot find the Winforms.dll file. Even after searching the entire C: drive.
Anyone else have this problem?
Anyone have the answer to this?
I'm using visual studio 2012 express and sql server 2012 express.
thank you!
Jeff
On Windows 8 I found the Microsoft.Reporting.WinForms.dll in a subdir of C:\windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\11.0.0.0__…..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|