Microsoft Reporting and parameters

If you use Microsoft Reporting, anyone that is used to work with ASP.NET 2.0 or later will be very familiar. In this example, I use the Northwind database (Microsoft Access – not SQL Server). Add the report file, create and configure the data source using the built in wizard, drag fields from the Data Sources window onto the report, and finally, if required, modify the typed dataset that the wizard supplied to you. To view a Microsoft Reporting report, use the Report Viewer control in the Data section of the toolbox.

In detail, open the typed dataset. Right click on the data table and click Configure. You should see a query looking something like this:

SELECT OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry FROM Orders

To add a parameter, append the following code to the query:

WHERE EmployeeID=?

Now, when you have stepped through the wizard, the Fill method of the corresponding data adapter has a new parameter: An employee ID is required! The parameter you send to the Fill method, will be used in the query. Imagine if everything was this easy!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll:

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Comments

Important information: If you have not commented before, your comment will be reviewed before it is published. This means that you will not see it immediately, but I have received it. This is not because I want to filter comments, but because I want to prevent spam and advertising.

Leave a Reply

Your email address will not be published. Required fields are marked *