Documentation errors in the ReportingService.Render Method topic, the ReportingService.CreateDataDrivenSubscription Method topic, and the ReportingService.CreateReportHistorySnapshot Method topic in Reporting Services Books Online

Article translations Article translations
Article ID: 842854 - View products that this article applies to.
Expand all | Collapse all

On This Page

INTRODUCTION

In Reporting Services Books Online, the following topics contain documentation errors:
  • "ReportingService.Render Method"
  • "ReportingService.CreateDataDrivenSubscription Method"
The "Example" section in each topic contains code samples that are not correct. This article contains the correct code samples for these topics. Additionally, the "ReportingService.CreateReportHistorySnapshot Method" topic does not contain complete information. This article contains the additional information to be included in the "ReportingService.CreateReportHistorySnapshot Method" topic.

MORE INFORMATION

The "ReportingService.Render Method" topic

The following documentation errors occur in the "ReportingService.Render Method" topic:
  • The introduction for the code sample in the "Example" section contains the following information:

    "The following code example renders a report in HTML 4.0 and saves it as an .htm file to disk:"

    This information should read as follows:

    "The following code example renders a report in MHTML and saves it as an .mhtml file to disk:"
  • In the code samples that are mentioned in the "Example" section, the devInfo render argument is initialized to a string value that is similar to <DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>. To correct the code, the string must be replaced with the Nothing value .

    Note Before you run these code samples, replace NameSpaceName with name of the namespace of the Reporting Services Web service. Typically, NameSpaceName is replaced with the name of the project. Replace WebReferenceName with the name of the Web Reference that corresponds to the Reporting Services Web service.

    The Microsoft Visual Basic code sample should read as follows:
    Imports System
    Imports System.IO
    Imports NameSpaceName.WebReferenceName
    Imports System.Web.Services.Protocols
    
    Class Sample
       Public Shared Sub Main()
          Dim rs As New ReportingService()
          rs.Credentials = System.Net.CredentialCache.DefaultCredentials
          
          ' Render arguments.
          Dim result As Byte() = Nothing
          Dim reportPath As String = "/SampleReports/Employee Sales Summary"
          Dim format As String = "MHTML"
          Dim historyID As String = Nothing
          Dim devInfo As String = Nothing
          
          ' Prepare report parameter.
          Dim parameters(2) As ParameterValue
          parameters(0) = New ParameterValue()
          parameters(0).Name = "EmpID"
          parameters(0).Value = "38"
          parameters(1) = New ParameterValue()
          parameters(1).Name = "ReportMonth"
          parameters(1).Value = "6" ' June
          parameters(2) = New ParameterValue()
          parameters(2).Name = "ReportYear"
          parameters(2).Value = "2004"
          
          Dim credentials As DataSourceCredentials() = Nothing
          Dim showHideToggle As String = Nothing
          Dim encoding As String
          Dim mimeType As String
          Dim warnings As Warning() = Nothing
          Dim reportHistoryParameters As ParameterValue() = Nothing
          Dim streamIDs As String() = Nothing
          Dim sh As New SessionHeader()
          rs.SessionHeaderValue = sh
          
          Try
             result = rs.Render(reportPath, format, historyID, devInfo, parameters, credentials, showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
             sh.SessionId = rs.SessionHeaderValue.SessionId
             Console.WriteLine("SessionID after call to Render: {0}", rs.SessionHeaderValue.SessionId)
             Console.WriteLine("Execution date and time: {0}", rs.SessionHeaderValue.ExecutionDateTime)
             Console.WriteLine("Is new execution: {0}", rs.SessionHeaderValue.IsNewExecution)
          Catch e As SoapException
             Console.WriteLine(e.Detail.OuterXml)
          End Try
          ' Write the contents of the report to an MHTML file.
          Try
             Dim stream As FileStream = File.Create("report.mhtml", result.Length)
             Console.WriteLine("File created.")
             stream.Write(result, 0, result.Length)
             Console.WriteLine("Result written to the file.")
             stream.Close()
          Catch e As Exception
             Console.WriteLine(e.Message)
          End Try
       End Sub 'Main
    End Class 'Sample
    
    The C# sample code should read as follows:
    using System;
    using System.IO;
    using NameSpaceName.WebReferenceName;
    using System.Web.Services.Protocols;
    
    class Sample
    {
    	public static void Main()
    	{
    ReportingService rs = new ReportingService();
    		rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
          
    		// Render arguments.
    		byte[] result = null;
    		string reportPath = "/SampleReports/Employee Sales Summary";
    		string format = "MHTML";
    		string historyID = null;
    		string devInfo = null;
    
    		// Prepare report parameter.
    		ParameterValue[] parameters = new ParameterValue[3];
    		parameters[0] = new ParameterValue();
    		parameters[0].Name = "EmpID";
    		parameters[0].Value = "38";
    		parameters[1] = new ParameterValue();
    		parameters[1].Name = "ReportMonth";
    		parameters[1].Value = "6"; // June
    		parameters[2] = new ParameterValue();
    		parameters[2].Name = "ReportYear";
    		parameters[2].Value = "2004";
    
    		DataSourceCredentials[] credentials = null;
    		string showHideToggle = null;
    		string encoding;
    		string mimeType;
    		Warning[] warnings = null;
    		ParameterValue[] reportHistoryParameters = null;
    		string[] streamIDs = null;
    		SessionHeader sh = new SessionHeader();
    		rs.SessionHeaderValue = sh;
    
    		try
    		{
    			result = rs.Render(reportPath, format, historyID, devInfo, parameters, credentials, 
    				showHideToggle, out encoding, out mimeType, out reportHistoryParameters, out warnings,
    				out streamIDs);
    			sh.SessionId = rs.SessionHeaderValue.SessionId;
    			Console.WriteLine("SessionID after call to Render: {0}", 
    				rs.SessionHeaderValue.SessionId);
    			Console.WriteLine("Execution date and time: {0}",
    				rs.SessionHeaderValue.ExecutionDateTime);
    			Console.WriteLine("Is new execution: {0}",
    				rs.SessionHeaderValue.IsNewExecution);
    		}
    		catch (SoapException e)
    		{
    			Console.WriteLine(e.Detail.OuterXml);
    		}
    		// Write the contents of the report to an MHTML file.
    		try
    		{
    			FileStream stream = File.Create( "report.mhtml", result.Length );
    			Console.WriteLine( "File created." );
    			stream.Write( result, 0, result.Length );
    			Console.WriteLine( "Result written to the file." );
    			stream.Close();
    		}
    		catch ( Exception e )
    		{
    			Console.WriteLine( e.Message );
    		}
    	}
    }
    

The "ReportingService.CreateDataDrivenSubscription Method" topic

The "ReportingService.CreateDataDrivenSubscription Method" topic includes the following documentation errors:
  • The signature of the CreateDataDrivenSubscription method must not contain the Name parameter. The signature of the CreateDataDrivenSubscription method must be read as follows:
    Public Sub CreateDataDrivenSubscription( _
       ByVal Report As String, _
       ByVal ExtensionSettings As [Namespace].ExtensionSettings, _
       ByVal DataRetrievalPlan As [Namespace].DataRetrievalPlan, _
       ByVal Description As String, _
       ByVal EventType As String, _
       ByVal MatchData As String, _
       ByVal Parameters() As [Namespace].ParameterValue _
    ) As String
       Member of [Namespace].ReportingService
    
  • In the code samples in the "Example" section, the Item property of the dataRetrieval object is not initialized. When you run the code samples, you may receive a message that is similar to the following:
    ReportingServicesWebServer The required field DataSourceDefinitionOrReference is missing from the input structure.
    The code samples must be updated with a line of code that is similar to the following:
    dataRetrieval.Item = dataSourceDefinition
    Note Before you run these code samples, replace NameSpaceName with name of the namespace of the Reporting Services Web service. Typically, NameSpaceName is replaced with the name of the project. Replace WebReferenceName with the name of the Web Reference that corresponds to the Reporting Services Web service, and replace saPassword with the password of the system administrator user sa. Make sure that you create a sample subscriber database named Employee that has a table named MailList. The MailList table must have a Name column, an EmailAddress column, an EmpID column, a Format column, and a Linked column.

    The Visual Basic sample code should read as follows:
    Imports System
    Imports NameSpaceName.WebReferenceName
    Imports System.Web.Services.Protocols
    
    Class Sample
       Public Shared Sub Main()
          Dim rs As New ReportingService()
          rs.Credentials = System.Net.CredentialCache.DefaultCredentials
          
          Dim report As String = "/SampleReports/Employee Sales Summary"
          Dim description As String = "My new data driven subscription"
          
          ' Set the extension setting as report server email.
          Dim settings As New ExtensionSettings()
          settings.Extension = "Report Server Email"
          
          ' Set the extension parameter values.
          Dim extensionParams(7) As ParameterValueOrFieldReference
          
          Dim [to] As New ParameterFieldReference() ' Data-driven.
          [to].ParameterName = "TO"
          [to].FieldAlias = "EmailAddress"
          extensionParams(0) = [to]
          
          Dim replyTo As New ParameterValue()
          replyTo.Name = "ReplyTo"
          replyTo.Value = "dank@adventure-works.com"
          extensionParams(1) = replyTo
          
          Dim includeReport As New ParameterValue()
          includeReport.Name = "IncludeReport"
          includeReport.Value = "False"
          extensionParams(2) = includeReport
          
          Dim renderFormat As New ParameterValue()
          renderFormat.Name = "RenderFormat"
          renderFormat.Value = "HTML4.0"
          extensionParams(3) = renderFormat
          
          Dim priority As New ParameterValue()
          priority.Name = "Priority"
          priority.Value = "NORMAL"
          extensionParams(4) = priority
          
          Dim subject As New ParameterValue()
          subject.Name = "Subject"
          subject.Value = "Your sales report"
          extensionParams(5) = subject
          
          Dim comment As New ParameterValue()
          comment.Name = "Comment"
          comment.Value = "Here is the link to your report."
          extensionParams(6) = comment
          
          Dim includeLink As New ParameterValue()
          includeLink.Name = "IncludeLink"
          includeLink.Value = "True"
          extensionParams(7) = includeLink
          
          settings.ParameterValues = extensionParams
          
          ' Create the data source for the delivery query.
          Dim delivery As New DataSource()
          delivery.Name = ""
          Dim dataSourceDefinition As New DataSourceDefinition()
          dataSourceDefinition.ConnectString = "data source=(local);initial catalog=Employee"
          dataSourceDefinition.CredentialRetrieval = CredentialRetrievalEnum.Store
          dataSourceDefinition.Enabled = True
          dataSourceDefinition.EnabledSpecified = True
          dataSourceDefinition.Extension = "SQL"
          dataSourceDefinition.ImpersonateUserSpecified = False
          dataSourceDefinition.UserName = "sa"
          dataSourceDefinition.Password = "saPassword"
          delivery.Item = dataSourceDefinition
          
          ' Create the fields list.
          Dim fieldsList(1) As Field
          fieldsList(0) = New Field()
          fieldsList(0).Name = "EmailAddress"
          fieldsList(0).Alias = "EmailAddress"
          fieldsList(1) = New Field()
          fieldsList(1).Name = "EmpID"
          fieldsList(1).Alias = "EmpID"
          
          ' Create the data set for the delivery query.
          Dim dataSetDefinition As New DataSetDefinition()
          dataSetDefinition.AccentSensitivitySpecified = False
          dataSetDefinition.CaseSensitivitySpecified = False
          dataSetDefinition.KanatypeSensitivitySpecified = False
          dataSetDefinition.WidthSensitivitySpecified = False
          dataSetDefinition.Fields = fieldsList
          Dim queryDefinition As New QueryDefinition()
          queryDefinition.CommandText = "Select * from MailList"
          queryDefinition.CommandType = "Text"
          queryDefinition.Timeout = 45
          queryDefinition.TimeoutSpecified = True
          dataSetDefinition.Query = queryDefinition
          Dim results As New DataSetDefinition()
          Dim changed As Boolean
          
          Try
             results = rs.PrepareQuery(delivery, dataSetDefinition, changed)
          Catch e As SoapException
             Console.WriteLine(e.Detail.InnerText.ToString())
          End Try
          
          Dim dataRetrieval As New DataRetrievalPlan()
          dataRetrieval.DataSet = results
          dataRetrieval.Item = dataSourceDefinition
          
          ' Set the event type and match data for the delivery.
          Dim eventType As String = "TimedSubscription"
          Dim matchData As String = "<ScheduleDefinition><StartDateTime>2003-04-14T19:15:00-07:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday><Tuesday>True</Tuesday><Wednesday>True</Wednesday><Thursday>True</Thursday><Friday>True</Friday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
          
          ' Set the report parameter values.
          Dim parameters(2) As ParameterValueOrFieldReference
          
          Dim empID As New ParameterFieldReference() ' Data-driven.
          empID.ParameterName = "EmpID"
          empID.FieldAlias = "EmpID"
          parameters(0) = empID
          
          Dim reportYear As New ParameterValue()
          reportYear.Name = "ReportYear"
          reportYear.Value = "2004"
          parameters(1) = reportYear
          
          Dim reportMonth As New ParameterValue()
          reportMonth.Name = "ReportMonth"
          reportMonth.Value = "6" ' June
          parameters(2) = reportMonth
          
          Try
             Dim subscriptionID As String = rs.CreateDataDrivenSubscription(report, settings, dataRetrieval, description, eventType, matchData, parameters)
          Catch e As SoapException
             Console.WriteLine(e.Detail.InnerText.ToString())
          End Try
       End Sub 'Main
    End Class 'Sample
    
    The C# sample code should read as follows:
    using System;
    using NameSpaceName.WebReferenceName;
    using System.Web.Services.Protocols;
    
    class Sample
    {
    	public static void Main()
    	{
    		ReportingService rs = new ReportingService();
    		rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
    		string report = "/SampleReports/Employee Sales Summary";
    		string description = "My new data driven subscription";
    
    		// Set the extension setting as report server email.
    		ExtensionSettings settings = new ExtensionSettings();
    		settings.Extension = "Report Server Email";
    
    		// Set the extension parameter values.
    		ParameterValueOrFieldReference[] extensionParams = 
    			new ParameterValueOrFieldReference[8];
    
    		ParameterFieldReference to = new ParameterFieldReference(); // Data-driven.
    		to.ParameterName = "TO";
    		to.FieldAlias = "EmailAddress"; 
    		extensionParams[0] = to;
    
    		ParameterValue replyTo = new ParameterValue();
    		replyTo.Name = "ReplyTo";
    		replyTo.Value ="dank@adventure-works.com";
    		extensionParams[1] = replyTo;
    
    		ParameterValue includeReport = new ParameterValue();
    		includeReport.Name = "IncludeReport";
    		includeReport.Value = "False";
    		extensionParams[2] = includeReport;
    
    		ParameterValue renderFormat = new ParameterValue();
    		renderFormat.Name = "RenderFormat";
    		renderFormat.Value = "HTML4.0";
    		extensionParams[3] = renderFormat;
    
    		ParameterValue priority = new ParameterValue();
    		priority.Name = "Priority";
    		priority.Value = "NORMAL";
    		extensionParams[4] = priority;
    
    		ParameterValue subject = new ParameterValue();
    		subject.Name = "Subject";
    		subject.Value = "Your sales report";
    		extensionParams[5] = subject;
    
    		ParameterValue comment = new ParameterValue();
    		comment.Name = "Comment";
    		comment.Value = "Here is the link to your report.";
    		extensionParams[6] = comment;
    
    		ParameterValue includeLink = new ParameterValue();
    		includeLink.Name = "IncludeLink";
    		includeLink.Value = "True";
    		extensionParams[7] = includeLink;
    
    		settings.ParameterValues = extensionParams;
    
    		// Create the data source for the delivery query.
    		DataSource delivery = new DataSource();
    		delivery.Name = "";
    		DataSourceDefinition dataSourceDefinition = new DataSourceDefinition();
    		dataSourceDefinition.ConnectString = "data source=(local);initial catalog=Employee";
    		dataSourceDefinition.CredentialRetrieval = CredentialRetrievalEnum.Store;
    		dataSourceDefinition.Enabled = true;
    		dataSourceDefinition.EnabledSpecified = true;
    		dataSourceDefinition.Extension = "SQL";
    		dataSourceDefinition.ImpersonateUserSpecified = false;
    		dataSourceDefinition.UserName = "sa";
    		dataSourceDefinition.Password = "saPassword";
    		delivery.Item = dataSourceDefinition;
    
    		// Create the fields list.
    		Field[] fieldsList = new Field[2];
    		fieldsList[0] = new Field();
    		fieldsList[0].Name = "EmailAddress";
    		fieldsList[0].Alias = "EmailAddress";
    		fieldsList[1] = new Field();
    		fieldsList[1].Name = "EmpID";
    		fieldsList[1].Alias = "EmpID";
    
    		// Create the data set for the delivery query.
    		DataSetDefinition dataSetDefinition = new DataSetDefinition();
    		dataSetDefinition.AccentSensitivitySpecified = false;
    		dataSetDefinition.CaseSensitivitySpecified = false;
    		dataSetDefinition.KanatypeSensitivitySpecified = false;
    		dataSetDefinition.WidthSensitivitySpecified = false;
    		dataSetDefinition.Fields = fieldsList;
    		QueryDefinition queryDefinition = new QueryDefinition();
    		queryDefinition.CommandText = "Select * from MailList";
    		queryDefinition.CommandType = "Text";
    		queryDefinition.Timeout = 45;
    		queryDefinition.TimeoutSpecified = true;
    		dataSetDefinition.Query = queryDefinition;
    		DataSetDefinition results = new DataSetDefinition();
    		bool changed;
    
    		try
    		{
    			results = rs.PrepareQuery(delivery, dataSetDefinition, out changed);
    		}
    		catch (SoapException e)
    		{
    			Console.WriteLine(e.Detail.InnerText.ToString());
    		}
    
    		DataRetrievalPlan dataRetrieval = new DataRetrievalPlan();
    		dataRetrieval.DataSet = results;
            dataRetrieval.Item = dataSourceDefinition;  
    		// Set the event type and match data for the delivery.
    		string eventType = "TimedSubscription";
    		string matchData = "<ScheduleDefinition><StartDateTime>2003-04-14T19:15:00-07:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday><Tuesday>True</Tuesday><Wednesday>True</Wednesday><Thursday>True</Thursday><Friday>True</Friday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>";
    
    		// Set the report parameter values.
    		ParameterValueOrFieldReference[] parameters = new ParameterValueOrFieldReference[3];
    
    		ParameterFieldReference empID = new ParameterFieldReference(); // Data-driven.
    		empID.ParameterName = "EmpID";
    		empID.FieldAlias = "EmpID";
    		parameters[0] = empID;
    
    		ParameterValue reportYear = new ParameterValue();
    		reportYear.Name = "ReportYear";
    		reportYear.Value = "2004";
    		parameters[1] = reportYear;
    
    		ParameterValue reportMonth = new ParameterValue();
    		reportMonth.Name = "ReportMonth";
    		reportMonth.Value = "6"; // June
    		parameters[2] = reportMonth;
    
    		try
    		{
    			string subscriptionID = rs.CreateDataDrivenSubscription( report, 
    				settings, dataRetrieval, description, eventType, matchData, parameters);
    		}
    		catch (SoapException e)
    		{
    			Console.WriteLine(e.Detail.InnerText.ToString());
    		}
    	}
    }
    

The "ReportingService.CreateReportHistorySnapshot Method" topic

The "Remarks" section of the "ReportingService.CreateReportHistorySnapshot Method" topic should include the following information:

When you use the CreateReportHistorySnapshot Reporting Services Web service method, the report history snapshots are created by using the default values of the report parameters. If you want to create the report history snapshots with different parameter values, you must use linked reports with the CreateReportHistorySnapshot Reporting Services Web service method.

REFERENCES

For more information, visit the following MSDN Web sites:
http://msdn2.microsoft.com/en-us/library/aa225827(SQL.80).aspx
http://msdn2.microsoft.com/en-us/library/aa225827(SQL.80).aspx
http://msdn2.microsoft.com/en-us/library/aa225819(SQL.80).aspx
For more information about how to create a sample subscriber database, see the "Create a Sample Subscriber Database" section of the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/aa237461(SQL.80).aspx

Properties

Article ID: 842854 - Last Review: April 3, 2007 - Revision: 1.2
APPLIES TO
  • Microsoft SQL Server 2000 Reporting Services
Keywords: 
kbdev kbreport kbhowto kbdocfix kbcode kbdocerr kbinfo KB842854

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com