none
ReportViewer control bug in Back event? (ServerReport SSRS 2005 SP3) RRS feed

  • Question

  • Hello all,

    I use the following code in the ReportViewer's Back resp. DrillThrough event to set missing datasource credentials:

    private void OnBack(object sender, BackEventArgs e)
    {
      ServerReport serverReport = (ServerReport)e.ParentReport;
      SetDataSourceCredentials(serverReport);
    }

     

    private void OnDrillthrough(object sender, DrillthroughEventArgs e)
    {
      ServerReport serverReport = (ServerReport)e.Report;
      SetDataSourceCredentials(serverReport);
    }

     

    private static void SetDataSourceCredentials(ServerReport serverReport)
    {
      ReportDataSourceInfoCollection rdsInfoCollection = serverReport.GetDataSources();
      List<DataSourceCredentials> dscList = new List<DataSourceCredentials>();
      foreach (ReportDataSourceInfo rdsInfo in rdsInfoCollection)
      {
        DataSourceCredentials dsc = new DataSourceCredentials();
        dsc.Name = rdsInfo.Name;
        dsc.UserId =
    "username";
        dsc.Password =
    "password";
        dscList.Add(dsc);
      }
      serverReport.SetDataSourceCredentials(dscList.ToArray());
    }

    If a report doesn't contain any datasources requiring authentication GetDataSources() will return an empty collection. In this case SetDataSourceCredentials() will be called using an empty list.

    Showing a report for the first time or using drill through this doesn't matter. But going back to the previous report will result in the following error message (translated from german): some parameters or credentials are missing.

    Workaround is easy (just don't call the method if all credentials are already supplied). I just wanted to give feedback resp. ask if i'm probably doing something wrong.

    Thanx in advance and best regards,
    Gerald

     

     

    Friday, September 11, 2009 11:34 AM