26994 total geeks with 3514 solutions
Recent challengers:
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
timsattemme
[b][url=http ://www.moncl erjacketsout letpro.com/] moncler jackets[/url ][/b] [url=http:// buymoncler84 1994.webs.co m]moncler jackets[/url ] [b][url=http ://www<stron g><a href="http:/ /www.moncler jacketsoutle tpro.com/">m oncler jackets</a>< /strong> <a href="http
timsattemme
<strong><a href="http:/ /www.moncler jacketsoutle tpro.com/">m oncler jackets</a>< /strong> <st rong><a href="http:/ /www.moncler jacketsoutle tpro.com/">o utlet moncler</a>< /strong> <br ><strong><a href="http:/ /www.moncler jacketsoutle tpro.com/">b uy moncler</a>< /str
timsattemme
[b][url=http ://www.finer eplicawatche s.net/]repli ca o<strong><a href="http:/ /www.finerep licawatches. net/">replic a omega watches</a>< /strong> <br > <strong><a href="http:/ /www.finerep licawatches. net/">replic a cartier watches</a>< /strong> <br >
timsattemme
[b][url=http ://www.somon clerjacket.c om/]moncler jackets[/url ][/b] [url=http:// monclerjacke tsale1046.we bs.com]moncl er jackets[/url ] [b][url=http ://www<stron g><a href="http:/ /www.somoncl erjacket.com /">moncler jackets</a>< /strong> <a href="http:/ /monclerj
timsattemme
<strong><a href="http:/ /www.somoncl erjacket.com /">moncler jackets</a>< /strong> <st rong><a href="http:/ /www.somoncl erjacket.com /">outlet moncler</a>< /strong> <br ><strong><a href="http:/ /www.somoncl erjacket.com /">buy moncler</a>< /strong> <br ><br><br><br ><br

Donate
Donate and help us fund new challenges
Donate!
Due Date: Aug 31
August Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Server sales show
signs of slight
surge
Ice cream headache
as black hat hacks
sack Dairy Queen
Like condoms, data
now comes in big
and HUGE sizes
Ofcom will not
probe lesbian
lizard snog in new
Dr Who
series
Software bug caught
Galileo sats in
landslide, no
escape from reality
Google testing
delivery-by-drone
down under
ANZACs make
pinkie-promise to
end Indonesia
spying
Feds salute plucky
human
ROBOT-FIGHTERS
Mozilla"s "Tiles"
ads debut in new
Firefox nightlies
Suppose they gave a
VMworld and vSphere
didn"t show up?
Slashdot
Why Women Have No
Time For Wikipedia
Software Error
Caused
Soyuz/Galileo
Failure
IBM Opens Up Its
Watson
Supercomputer To
Researchers
The Executive Order
That Led To Mass
Spying, As Told By
NSA Alumni
Canada Tops List of
Most
Science-Literate
Countries
Brian Stevens
Resigns As Red Hat
CTO
Drought Inspires a
Boom In
Pseudoscience, From
Rain Machines To
"Water Witches"
Judge Lucy Koh
Rejects Apple"s
Quest For
Anti-Samsung
Injunction
No, a Stolen iPod
Didn"t Brick Ben
Eberle"s Prosthetic
Hand
State of the
GitHub: Chris Kelly
Does the Numbers
Article viewer

List parameters from an SSRS (SQL Server Reporting Services) report into an expression.



Written by:bb
Published by:bb
Published on:2006-10-24 07:55:46
Topic:Dot.Net
Search OSI about Dot.Net.More articles by bb.
 viewed 23191 times send this article printer friendly

Digg this!
    Rate this article :
How to get a list of parameters and their values from an SSRS (SQL Server Reporting Services) report from within an expression of the report. Its a nice way to echo out all parameters a report was run with without having to hardcode and means you can implement standard footers easily.

I found some tips for doing this on James Kovacs' Weblog. But the code wasnt there, so here it is if you wish to implement it. Another useful msdn article is here.

I am using the imported DLL mechanism of writing code for reports (rather than the inline Code section) Simply add this method to an assembly and reference it in your report. Remember to copy the dll to "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\" to test it when previewing from Visual Studio.

To call this function put a TextBox on your report, edit the expression and add the line
=YourDll.DisplayParams(Parameters, "Param1, Param2");


The function for the assembly
using Microsoft.ReportingServices.ReportProcessing.ReportObjectModel;

///
/// Builds a list of SQL Server Reporting Services Parameters based on a parameter object
/// and a comma delimited string of param names
///
public static string DisplayParams(Parameters obj, string strParams)
{
    StringBuilder sbRet = new StringBuilder();
    try
    {
        //parameters in comma delimited list which matches
        //the name of the parameter in the collection.
        foreach (string sParam in strParams.Split(','))
        {
            //the name of the parameter
            sbRet.Append(String.Format("{0}: ", sParam));

            //concat parmaeter values
            if (obj[sParam].IsMultiValue)
                for (int i = 0; i < obj[sParam].Count - 1; i++)
                    sbRet.Append(String.Format("{0} : ",
                            ((string[])obj[sParam].Label)[i]).Trim());
            else
                sbRet.Append(String.Format("{0}", obj[sParam].Label).Trim());

            //remove any trailing commas
            if (sbRet.ToString().EndsWith(", "))
                sbRet.Remove(sbRet.Length - 2, 2);

                        // seperator for each parameter
                        sbRet.Append("; ");
        }
    }
    catch (Exception)
    {
        return "Error building parameter list";
    }

    return sbRet.ToString();
}

Did you like this article? There are hundreds more.

Comments:
<none>
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
bb
ASP.NET RadioButton GroupName when inside a Repeater on Sun 10th Jun 8am
I was thankful on finding this nugget of code, which makes the groupname work out when slamming in radiobuttons in an asp.net repeater. http://www.codeguru.com/csharp/csharp/cs _controls/custom/article.php/c12371/


     
Your Ad Here
 
Copyright Open Source Institute, 2006