Sunday, February 19, 2012

How to defne a globale variable in the report

I want's to define some global contant variable which contains some values

Like Name="Abc"

Age=123

Date=12/12/2006

How can i define it on sql server reporting serices report and access it value to assign on some fields?

You could use hidden parameters with default values I guess.

1 - Add a parameter to your report and set it to the correct type (string / number etc) and mark it as hidden

2 - Set the default value that you want for it

3 - In your report, access it with something like "=Parameters!theParameter.Value"

Regards Andreas

|||

On the report properties, click on the Code tab and define it there, e.g.

Public Dim Age as Integer = 123

Then, you can reference it in the report as =Code.Age

|||

Which approach will be best for performance?

Can anybody give the pros and cons of the both approaches .

|||

If you want to be able to change the defined variables when calling a report it's good to have them as parameters. Lets say you programatically calls the report because you want to render a report in a WinForms app or something and want to be able to set the parameters from the winForms app, then the hidden parameter way is a good way I guess.

Otherwise, I suggest you do as Teo says.

Regards Andreas

|||

hi,

but parameters are readonly.

You cant set them through your custom code.

hemant

No comments:

Post a Comment