Share via


レッスン 4 : プログラムによるレポート定義の更新

新規 : 2006 年 7 月 17 日

前のレッスンでは、レポート サーバーからレポート定義を読み込み、レポート フィールドにその参照を指定しました。次は、レポート定義を更新する必要があります。この例では、レポートの Description プロパティを更新します。

レポート定義を更新するには

  1. Program.cs ファイル (Visual Basic では Module1.vb) 内で、UpdateReportDefinition() メソッド用のコードを次のコードに置き換えます。

    private void UpdateReportDefinition()
    {
        System.Console.WriteLine("Updating Report Definition");
    
        // Create a list of the Items Choices for the Report. The 
        // ItemsChoiceType37 enum represents all the properties
        // available in the report and the ItemsElementName 
        // represents the properties that exist in the current 
        // instance of the report.
        List<ItemsChoiceType37> _reportItems = 
            new List<ItemsChoiceType37>(_report.ItemsElementName);
    
        // Locate the index for the Description property
        int index = _reportItems.IndexOf(
            ItemsChoiceType37.Description);
    
        System.Console.WriteLine("- Old Description: " + 
                                 _report.Items[index]);
    
        // Update the Description for the Report
        _report.Items[index] = "New Report Description";
    
        System.Console.WriteLine("- New Description: " + 
                                 _report.Items[index]);
    }
    
    Private Sub UpdateReportDefinition()
    
        System.Console.WriteLine("Updating Report Definition")
    
        'Create a list of the Items Choices for the Report. The 
        'ItemsChoiceType37 enum represents all the properties
        'available in the report and the ItemsElementName 
        'represents the properties that exist in the current 
        'instance of the report.
        Dim reportItems As List(Of ItemsChoiceType37) = _
            New List(Of ItemsChoiceType37)(m_report.ItemsElementName)
    
        'Locate the index for the Description property
        Dim index As Integer = _
            reportItems.IndexOf(ItemsChoiceType37.Description)
    
        System.Console.WriteLine("- Old Description: " & _
                                 m_report.Items(index))
    
        'Update the Description for the Report
        m_report.Items(index) = "New Report Description"
    
        System.Console.WriteLine("- New Description: " & _
                                 m_report.Items(index))
    
    End Sub
    

次のレッスン

次のレッスンでは、更新したレポート定義をもう一度レポート サーバーに保存します。「レッスン 5 : レポート サーバーへのレポート定義のパブリッシュ」を参照してください。

参照

処理手順

チュートリアル : RDS スキーマから生成されたクラスを使ったレポートの更新

その他の技術情報

レポート定義言語

ヘルプおよび情報

SQL Server 2005 の参考資料の入手