- connect to any reporting server
- use default credentials or
- pass a username and password combination
- get the list of reports dynamically
- I want to decide how many reports I would like to see
- Create a new Winform application in Visual Studio.
- Place the following controls on the form:
A Textbox for the server URL
A Combobox used to populate with a list of available reports
Two buttons - one to fill the combo and one to run the report
A tab control with two pages and on both pages we need a ReportViewer control
Let's start coding
We need to create a web reference (right mouse button on References in solution explorer) which gives us a local proxy to the reporting server web service (the url for a local installation is http://localhost/reportserver/reportservice.asmx). I gave it the name RSWebService.
We need to instance variables to hold the web service proxy and the current ReportViewer control:
private ReportingService _rs = null;
private ReportViewer _currentViewer;
Also, a small helper class to hold the report name and report URL comes in handy:
The next thing we need to code is the button to connect to the web service using the proxy, retrieve a list of reports and fill the combobox. You see the full code below (click on the image to get it readable).
Now, our users would like to choose a report and show the report in the tab page.
Last but not least we would like to create a new tab page with a ReportViewer control on it if the user clicks on the last tab page on the tab control - which means we have to code the
SelectedIndexChanged event as you can see below.
Conclusion
Rporting server is really a cool piece of Microsoft SQL Server. With this small helper application development with it becomes even more fun and a bit easier (at least for me).
I hope you enjoyed this small article!