Have you ever written a report in Reporting Services 2005? Most of the people, but to get something worth of salt is necessary to have some experience rather advanced T-SQL or have a good background in databases to be productive in SQL Reporting Services. For those of you who are experts in procedural language like C #. NET or VB.NET, but not in T-SQL This article is for you. In this post I'm going to show a quick and dirty way to get a code of your advanced work in yourreports.
First of all, you need to know what your options are before you begin:
You can create custom groups in all. NET-compliant language of your choice
You can embed the code in Visual Basic report directly
This article is to discuss the second option because it is easier and faster to get your custom code to work than the first option. Do not get me wrong there are good reasons for both and you better know when to use one over the other incertain situations.
Now that we know what we're trying to accomplish, lets dig into some code!
Step 1: Build a relationship
- Building dataset
- Build the Report Layout
Step 2: Add a custom code for the report to do something useful
-Click Properties> Reports Reports
Click the Code tab-
This is where you put your custom code and reference in the report. Some things to consider:
All code that is in this block should be visuallyBasic. NET. All the code that runs here is run with full trust permissions when using the 'Preview'. In order to get custom authenication hops, ie as database calls, you must add the assembly and the necessary permissions. When the show calls to the database, web services calls, you must set the level of confidence in the web.config file on the report server. Furthermore, no additional library is used, ie System.Data.SqlClient must be explicitly referenced in the References tab.Any code that is used here can be directly used in any part of the report via '= Code.Method ()' syntax. If you are just building functions of this job, but if you put the class in the code will need to refer to the class as Code.ClassName.MethodName () to access it.
Step 3: Write some code Visual Basic NET.
- I prefer to write code in a Visual Studio class library project in order to get the benefit of IntelliSense and fill-timecontrol. Once I get what I need, I copy the code tab of the window> Report Properties reports this way.
- Visual Studio Code window
- Copy the code in the card code
- Enter the code in your relationship where you want
- Run the report to see what your logic returns
Conclusion
To recap what we did was pretty basic in terms of complexity, but gives us the power. NET Framework in our relations. Because Reporting Services usesprocessing engine based on expressions you can do many things for the whole relationship dynamic. I personally think that this is the best way to add custom logic that you could not do otherwise. However, we could have coded this logic in an IIF () statement in the report and it would work as well, but the point I'm trying to make is that we can use. NET Framework, to help us write better reports faster and more efficient.
No comments:
Post a Comment