In this article I explain how to use the Report Viewer with a dataset in Visual Studio 2012.
In my last article I explained how to create a SSRS project. In this article I explain how to use the Report Viewer in Visual Studio 2012. In this article we will see use of a dataset and the Report Viewer.
Step 1: Open Visual Studio 2012 or 2010 then create a new Forms Application (project name: "HowToOpenReportViewer").Step 2
Step 3: We need to create a dataset. How? Right-click on the HowToOpenReportViewer project then select "Add" >> "New Item" then select "DataSet". The default name is "DataSet1.xsd"; I did not change it. Then click the "OK" button.Here is the default DataSet page.Step 4: Right-click then select "Add" -> "TableAdapter"
In this screen we can set a connection configuration. If you have no connection struct then you should create a new connection fron the "New Connection". Step 5
Step 6: If you have Stores Procedures then you should choose the second button; I chose "SQL Statement". Then click the "Next" button. Step 7: We should use a SQL query for ComboBox. Step 8: This query will use a ComboBox.Step 9: Here is my method's name. If you want to change it, you can do that but I do not want to change it. I'll use the default name.Step 10: All the configuration is there. If you are not sure of the settings then you should click the "Previous" button.Step 11: I will create a DataAdapter two times for the display value. Step 12: Click the ComboBox then select "Use Data Bound Items".
Data Source: ProductsDisplay Member: ProductNameValue Member: ProductID and then we see the ProductName in the ComboBox.Step 13: Click "Report Viewer" then select "Desing a new Report".
Step 14: Note the option here to group the data and show it. It depends on your report's structure.
Step 15Step 16: Remember the SSRS Project :D In this page we see 6 default templates. I chose the Slate template and all of the users see that. Then click the "Next" button.Step 17Step 18
Add one button and name "Display". Step 19: Click "Report Viewer" then select "Choose Report".And the result is here:
Printing in C# Made Easy