2013-05-28 77 views
0

您好,我在为ASP.NET页面中的服务器上部署的SSRS报告提供参数时出错。无法将参数传递给ASP.NET页面中的SSRS报告

请参考下面的代码,让我知道问题在哪里?

ReportExecutionService rs = new ReportExecutionService(); 
     string rptURL = System.Configuration.ConfigurationManager.AppSettings["rptURL"].ToString(); 
     string rptPath = System.Configuration.ConfigurationManager.AppSettings["Page1SLScorecardReortForDownload"].ToString(); 
     //Microsoft.Reporting.WebForms.ReportParameter[] paramlist = new Microsoft.Reporting.WebForms.ReportParameter[3]; 
     //paramlist[0] = new Microsoft.Reporting.WebForms.ReportParameter("Week", "2013-05-03"); 
     //paramlist[1] = new Microsoft.Reporting.WebForms.ReportParameter("year", "Fiscal Calendar 2013"); 
     //paramlist[2] = new Microsoft.Reporting.WebForms.ReportParameter("Month", "Fiscal May, 2013"); 
     ParameterValue[] paramlist = new ParameterValue[3]; 
     //Microsoft.Reporting.WebForms.ReportParameter[] paramlist = new Microsoft.Reporting.WebForms.ReportParameter[3]; 
     paramlist[0] = new ParameterValue(); 
     paramlist[0].Name = "Week"; 
     paramlist[0].Value = "2013-05-03"; 
     paramlist[1] = new ParameterValue(); 
     paramlist[1].Name = "year"; 
     paramlist[1].Value = "Fiscal Calendar 2013"; 
     paramlist[2] = new ParameterValue(); 
     paramlist[2].Name = "Month"; 
     paramlist[2].Value = "Fiscal May, 2013"; 

     //ReportViewer1.ServerReport.SetParameters(paramlist); 

     rs.Credentials = System.Net.CredentialCache.DefaultCredentials; 
     rs.Url = rptURL; 
     byte[] result = null; 
     string reportPath = rptPath; 
     string format = "EXCEL"; 
     string historyID = null; 
     string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"; 

     string encoding; 
     string mimeType; 
     string extension; 
     ReportingWS.Warning[] warnings = null; 
     string[] streamIDs = null; 
     ReportingWS.ExecutionInfo execInfo = new ReportingWS.ExecutionInfo(); 

     ReportingWS.ExecutionHeader execHeader = new ReportingWS.ExecutionHeader(); 
     rs.ExecutionHeaderValue = execHeader; 

     execInfo = rs.LoadReport(reportPath, historyID); 
     rs.SetExecutionParameters(paramlist, "en-us"); 
     String SessionId = rs.ExecutionHeaderValue.ExecutionID; 

     try 
     { 
      result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); 
      execInfo = rs.GetExecutionInfo(); 
     } 
     catch (Exception ex) 
     { 
      //AlnErrorHandler.HandleError(ex); 
     } 

回答

0
  parameters.Add(new ReportParameter("FyId", Convert.ToInt16(objSession.FyId).ToString())); 
      parameters.Add(new ReportParameter("AccountGroupId", cmbAccountGroup.SelectedValue)); 
      parameters.Add(new ReportParameter("LedgerId", cmbLedgerId.SelectedValue));    
      rptvwMain.ServerReport.SetParameters(parameters); 

传递参数类似这样的....

+0

不工作。它说构造函数不会带两个值。我想强调一点,我并不想将参数传递给报告查看器,因为我在anothere报告中做了这样的事情,并且参数很容易传递给reportviewer。我想获得报告的结果并在稍后写入文件。 – Richa

相关问题