2012-03-21 4 views
0

ASP.NET (MVC) 기반 응용 프로그램에서보고 서비스 보고서를 생성 중이지만 보고서 매개 변수를 설정하는 데 문제가 있습니다.Reporting Services 매개 변수를 설정할 수 없습니다.

SQL Server를 2005에서 2008 R2 (및 Reporting Services와 함께)로 업그레이드 한 이후에만 문제가 발생했다고 생각합니다. 원래 오류가 발생

는 호출 rsExec.Render에서였다

절차 또는 함수 'pCommunication_ReturnRegistrationLetterDetails' 파라미터가 제공되지 않은 '@guid'기대한다. 내가 rsExec.SetExecutionParameters는 다음과 같은 응답이 반환하는 것으로 나타났습니다 코드 디버깅

:

가 호출 할 수 없습니다

'NameOfApp.SQLRSExec.ReportExecutionService.SetExecutionParameters (NameOfApp.SQLRSExec.ParameterValue [], 문자열)' 그것은 웹 메소드이기 때문입니다. 여기

그것의 전체 기능입니다 :

public static bool ProduceReportToFile(string reportname, string filename, string[,] reportparams, 
    string fileformat) 
{ 
    bool successful = false; 
    SQLRS.ReportingService2005 rs = new SQLRS.ReportingService2005(); 
    SQLRSExec.ReportExecutionService rsExec = new NameOfApp.SQLRSExec.ReportExecutionService(); 

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials; 
    rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials; 

    // Prepare Render arguments 
    string historyID = null; 
    string deviceInfo = null; 

    // Prepare format - available options are "PDF","Word","CSV","TIFF","XML","EXCEL" 
    string format = fileformat; 

    Byte[] results; 
    string encoding = String.Empty; 
    string mimeType = String.Empty; 
    string extension = String.Empty; 

    SQLRSExec.Warning[] warnings = null; 
    string[] streamIDs = null; 

    // Define variables needed for GetParameters() method 
    // Get the report name 
    string _reportName = reportname; 
    string _historyID = null; 
    bool _forRendering = false; 
    SQLRS.ParameterValue[] _values = null; 
    SQLRS.DataSourceCredentials[] _credentials = null; 
    SQLRS.ReportParameter[] _parameters = null; 

    // Get if any parameters needed. 
    _parameters = rs.GetReportParameters(_reportName, _historyID, 
        _forRendering, _values, _credentials); 

    // Load the selected report. 
    SQLRSExec.ExecutionInfo ei = 
      rsExec.LoadReport(_reportName, historyID); 

    // Prepare report parameter. 
    // Set the parameters for the report needed. 
    SQLRSExec.ParameterValue[] parameters = 
      new SQLRSExec.ParameterValue[1]; 

    // Place to include the parameter. 
    if (_parameters.Length > 0) 
    { 
     for (int i = 0; i < _parameters.Length; i++) 
     { 
      parameters[i] = new SQLRSExec.ParameterValue(); 
      parameters[i].Label = reportparams[i,0]; 
      parameters[i].Name = reportparams[i, 0]; 
      parameters[i].Value = reportparams[i, 1]; 
     } 
    } 
    rsExec.SetExecutionParameters(parameters, "en-us"); 
    results = rsExec.Render(format, deviceInfo, 
       out extension, out encoding, 
       out mimeType, out warnings, out streamIDs); 

    // Create a file stream and write the report to it 
    using (FileStream stream = System.IO.File.OpenWrite(filename)) 
    { 
     stream.Write(results, 0, results.Length); 
    } 
    successful = true; 

    return successful; 
} 

지금 매개 변수를 설정할 수 없습니다 해요 왜 어떤 아이디어? 매개 변수가 필요하지 않은 경우 보고서 생성은 문제없이 작동합니다.

답변

0

보고 서비스가 매개 변수를 통해 데이터를 제공하는 저장 프로 시저로 전달하는 방법에 문제가있는 것처럼 보입니다. 문자열 GUID가 보고서로 전달되고 저장 프로 시저에서 varchar guid가 필요합니다. 나는보고 서비스가 guid 형식 패턴을 따르는 문자열을 알아 차렸을 수도 있으므로이를 저장 프로 시저에 대한 고유 식별자로 전달했습니다.

보고서의 데이터 소스를 "저장 프로 시저"에서 "텍스트"로 변경하고 SQL을 "EXEC pMyStoredOProcName @guid"로 설정했습니다.

저장 프로 시저에 문자열로 전달되는 GUID는 아마도 모범 사례가 아니므로 ... 다른 개발자 코드로 문제를 디버깅하는 중일뿐입니다.

0

매개 변수 _reportName은 null 또는 비워 둘 수 없습니다. [CLASSNAME].[METHODNAME]() 리플렉션 API는 SrsReportNameAttribute 개체를 생성하고 반환 할 수 없습니다.

이 경우에는 이전의 전체 컴파일이 완료되지 않은 것처럼 보입니다.

이 문제가 발생하면 먼저 오류 메시지에 언급 된 클래스를 컴파일하고 이것이 문제를 해결하는지 확인하십시오.

  1. 클래스에서

  2. 가 CLASSNAME

찾을 AOT (수 Ctrl 키 + D)로 이동 3.compile 그것 (F7)

관련 문제