Report parameters use old value instead of new null value RRS feed

  • Question

  • Hi,

    I have a problem with passing null parameters to my report, after I have fetched the report once with a non-null values for the same parameters.


    I have an .aspx-page with controls for entering report parameters, a button for fetching the report, and a ReportViewer control that shows the report. When the user hits the button, my web page collects the values from the controls, creates report parameters, configures the ReportViewer control with (among others) the correct report path and report parameters, and the report is shown in the ReportViewer.

    The first time, everything goes fine. But, if the user the first time gives
    parameterX = 1, parameterY = 20, parameterZ = null
    and the second time
    parameterX = 2, parameterY = null, parameterZ = 30
    the report uses
    parameterX = 2, parameterY = 20, parameterZ = 30.

    That is, the report uses any new non-null value that is given, but if null is specified for a parameter for which a value previously has been specified, the old values are used instead.

    I have this problem with several different reports in several different .aspx-pages and several different applications, all on my local web server. It appears with Microsoft IE as well as Firefox. The same report, when running on another server, works correctly. My ReportServer configuration files are identical to the configuration files on another system, where the reports run correctly. The report is always run on demand, no caching or snapshots are used.

    When I run my code in a debugger, the parameter collection is set correctly. However, the SQL Server profiler shows that the procedure call (which generates the data for the report) uses all the new  non-null parameter values and for parameters that have null values specified, the most recently previously specified value.

    All parameters are reset when I start a new session.

    It seems like this has something to do with how the parameters are stored in the session before being passed to the reporting server. Does anyone know what IIS setting (or something else) that would solve this problem? I've tried to compare my IIS settings (MetaBase.bin) to the Metabase.bin on a similar system without the null parameter problem, but found nothing useful so far.

    I use IIS 5.1, ASP.NET 2.0.

    The code bit (modified) that sets the parameters:
    ReportParameter paramX = null;
    if (dropdownlistValuesForX.SelectedIndex > -1 &&
        dropdownlistValuesForX.SelectedValue.Length > 0)
        paramX = new ReportParameter("parameterX");
        paramX = new ReportParameter("parameterX",


    reportViewer.ServerReport.SetParameters(new ReportParameter[] {paramX, paramY, paramZ};

    Does anyone have a solution to this problem?

    Thankful for any hints (and for patience with the long post),

    Friday, June 29, 2007 9:16 AM

All replies

  • Did you find the solution?


    Im having the same problem and hope you can help me.


    The NULL values are ignored and old values are being used... very annoying.


    HELP Please

    Monday, October 22, 2007 8:28 AM
  • For people that would like to recreate the problem:


    Add a ReportViewer to your page.

    Add the credential class:

    Code Block


    public sealed class MyReportServerCredentials :



    public WindowsIdentity ImpersonationUser




    // Use the default Windows user. Credentials will be

    // provided by the NetworkCredentials property.

    return null;



    public ICredentials NetworkCredentials




    // Read the user information from the Web.config file.

    // By reading the information on demand instead of

    // storing it, the credentials will not be stored in

    // session, reducing the vulnerable surface area to the

    // Web.config file, which can be secured with an ACL.

    // User name

    string userName =



    if (string.IsNullOrEmpty(userName))

    throw new Exception(

    "Missing user name from web.config file");

    // Password

    string password =



    if (string.IsNullOrEmpty(password))

    throw new Exception(

    "Missing password from web.config file");

    // Domain

    string domain =



    if (string.IsNullOrEmpty(domain))

    throw new Exception(

    "Missing domain from web.config file");

    return new NetworkCredential(userName, password, domain);



    public bool GetFormsCredentials(out Cookie authCookie,

    out string userName, out string password,

    out string authority)


    authCookie = null;

    userName = null;

    password = null;

    authority = null;

    // Not using form credentials

    return false;





    Use like so:

    RViewer.ServerReport.ReportServerCredentials = new MyReportServerCredentials();


    Adding a parameter:

    Code Block

    string name = ((TextBox)mainPlaceHolder.Controls[i]).ID.Replace("TextBox_", "");

    string value = ((TextBox)mainPlaceHolder.Controls[i]).Text;

    if (value.Length > 0)

    parameters[t++] = new Microsoft.Reporting.WebForms.ReportParameter(name, value);



    parameters[t++] = new Microsoft.Reporting.WebForms.ReportParameter(name);




    Send parameters and refresh

    Code Block







    This will always work for non-NULL values, but a sequence of

    1. "hello"

    2. null


    will result in "hello" and not NULL as expected.


    Any help will be appreciated.

    Monday, October 22, 2007 1:10 PM



    Anyone please help

    Tuesday, January 15, 2008 1:51 PM