Share via


3단원: 보고서 서버에서 보고서 정의 로드

프로젝트를 만들고 RDL 스키마에서 클래스를 생성하면 보고서 서버에서 보고서 정의를 로드할 준비가 됩니다.

보고서 정의를 로드하려면

  1. Report 클래스에 대한 ReportUpdater 클래스(Visual Basic을 사용 중인 경우 모듈)의 맨 위에 private 필드를 추가합니다. 이 필드는 응용 프로그램의 수명이 지속되는 동안 보고서 서버에서 로드된 보고서에 대한 참조를 유지 관리하는 데 사용됩니다.

    private Report _report;
    
    Private m_report As Report
    
  2. Program.cs 파일(Visual Basic의 경우 Module1.vb)에서 LoadReportDefinition() 메서드의 코드를 다음 코드로 바꿉니다.

    private void LoadReportDefinition()
    {
        System.Console.WriteLine("Loading Report Definition");
    
        string reportPath = 
            "/AdventureWorks 2012 Sample Reports/Company Sales 2012";
    
        // Retrieve the report defintion 
        // from the report server
        byte[] bytes = 
            _reportService.GetItemDefinition(reportPath);
    
        if (bytes != null)
        {
            XmlSerializer serializer = 
                new XmlSerializer(typeof(Report));
    
            // Load the report bytes into a memory stream
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                // Deserialize the report stream to an 
                // instance of the Report class
                _report = (Report)serializer.Deserialize(stream);
            }
        }
    }
    
    Private Sub LoadReportDefinition()
    
        System.Console.WriteLine("Loading Report Definition")
    
        Dim reportPath As String = _
            "/AdventureWorks 2012 Sample Reports/Company Sales 2012"
    
        'Retrieve the report defintion 
        'from the report server
        Dim bytes As Byte() = _
            m_reportService.GetItemDefinition(reportPath)
    
        If Not (bytes Is Nothing) Then
    
            Dim serializer As XmlSerializer = _
                New XmlSerializer(GetType(Report))
    
            'Load the report bytes into a memory stream
            Using stream As MemoryStream = New MemoryStream(bytes)
    
                'Deserialize the report stream to an 
                'instance of the Report class
                m_report = CType(serializer.Deserialize(stream), _
                                 Report)
    
            End Using
    
        End If
    
    End Sub
    

다음 단원

다음 단원에서는 코드를 작성하여 보고서 서버에서 로드된 보고서 정의를 업데이트합니다. 4단원: 프로그래밍 방식으로 보고서 정의 업데이트를 참조하십시오.

참고 항목

태스크

RDL 스키마에서 생성한 클래스를 사용하여 보고서 업데이트(SSRS 자습서)

개념

SSRS(Report Definition Language)