--- title: "Lesson 4: Update the Report Definition Programmatically | Microsoft Docs" ms.custom: "" ms.date: "03/06/2017" ms.prod: "sql-server-2014" ms.reviewer: "" ms.technology: reporting-services-native ms.topic: conceptual ms.assetid: 1f0a1d46-6d6d-4f67-b51e-06dbbbffacf9 author: markingmyname ms.author: maghan manager: kfile --- # Lesson 4: Update the Report Definition Programmatically Now that the report definition has been loaded from the report server and you have a reference to it using the report field, you need to update the report definition. For this example, you will update the `Description` property for the report. ### To update the report definition 1. Replace the code for the UpdateReportDefinition() method in the Program.cs file (Module1.vb for [!INCLUDE[vbprvb](../includes/vbprvb-md.md)]) with the following code: ```csharp private void UpdateReportDefinition() { System.Console.WriteLine("Updating Report Definition"); // Create a list of the Items Choices for the Report. The // ItemsChoiceType118 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 _reportItems = new List(_report.ItemsElementName); // Locate the index for the Description property int index = _reportItems.IndexOf( ItemsChoiceType118.Description); // The Description item is of type StringLocIDType, so // cast the item type first and then assign new value. System.Console.WriteLine("- Old Description: " + ((StringLocIDType)_report.Items[index]).Value ); // Update the Description for the Report ((StringLocIDType)_report.Items[index]).Value = "New Report Description"; System.Console.WriteLine("- New Description: " + ((StringLocIDType)_report.Items[index]).Value ); } ``` ```vb Private Sub UpdateReportDefinition() System.Console.WriteLine("Updating Report Definition") 'Create a list of the Items Choices for the Report. The 'ItemsChoiceType118 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 ItemsChoiceType118) = _ New List(Of ItemsChoiceType118)(m_report.ItemsElementName) 'Locate the index for the Description property Dim index As Integer = _ reportItems.IndexOf(ItemsChoiceType118.Description) 'The Description item is of type StringLocIDType, so 'cast the item type first and then assign new value. System.Console.WriteLine("- Old Description: " & _ DirectCast(m_report.Items(index), StringLocIDType).Value) 'Update the Description for the Report DirectCast(m_report.Items(index), StringLocIDType).Value = _ "New Report Description" System.Console.WriteLine("- New Description: " & _ DirectCast(m_report.Items(index), StringLocIDType).Value) End Sub ``` ## Next Lesson In the next lesson, you will save the updated report definition back to the report server. See [Lesson 5: Publish the Report Definition to the Report Server](../../2014/tutorials/lesson-5-publish-the-report-definition-to-the-report-server.md). ## See Also [Updating Reports Using Classes Generated from the RDL Schema (SSRS Tutorial)](../../2014/tutorials/updating-reports-using-classes-generated-from-the-rdl-schema-ssrs-tutorial.md)