Microsoft KB Archive/842854

= 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 ID: 842854

Article Last Modified on 4/3/2007

-

APPLIES TO


 * Microsoft SQL Server 2000 Reporting Services

-



INTRODUCTION
In Reporting Services Books Online, the following topics contain documentation errors:
 * &quot;ReportingService.Render Method&quot;
 * &quot;ReportingService.CreateDataDrivenSubscription Method&quot;

The &quot;Example&quot; section in each topic contains code samples that are not correct. This article contains the correct code samples for these topics. Additionally, the &quot;ReportingService.CreateReportHistorySnapshot Method&quot; topic does not contain complete information. This article contains the additional information to be included in the &quot;ReportingService.CreateReportHistorySnapshot Method&quot; topic.



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

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

This information should read as follows:

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

Note Before you run these code samples, replace  with name of the namespace of the Reporting Services Web service. Typically,  is replaced with the name of the project. Replace  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 = &quot;/SampleReports/Employee Sales Summary&quot; Dim format As String = &quot;MHTML&quot; 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 = &quot;EmpID&quot; parameters(0).Value = &quot;38&quot; parameters(1) = New ParameterValue parameters(1).Name = &quot;ReportMonth&quot; parameters(1).Value = &quot;6&quot; ' June parameters(2) = New ParameterValue parameters(2).Name = &quot;ReportYear&quot; parameters(2).Value = &quot;2004&quot; 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(&quot;SessionID after call to Render: {0}&quot;, rs.SessionHeaderValue.SessionId) Console.WriteLine(&quot;Execution date and time: {0}&quot;, rs.SessionHeaderValue.ExecutionDateTime) Console.WriteLine(&quot;Is new execution: {0}&quot;, 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(&quot;report.mhtml&quot;, result.Length) Console.WriteLine(&quot;File created.&quot;) stream.Write(result, 0, result.Length) Console.WriteLine(&quot;Result written to the file.&quot;) 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 = &quot;/SampleReports/Employee Sales Summary&quot;; string format = &quot;MHTML&quot;; string historyID = null; string devInfo = null;

// Prepare report parameter. ParameterValue[] parameters = new ParameterValue[3]; parameters[0] = new ParameterValue; parameters[0].Name = &quot;EmpID&quot;; parameters[0].Value = &quot;38&quot;; parameters[1] = new ParameterValue; parameters[1].Name = &quot;ReportMonth&quot;; parameters[1].Value = &quot;6&quot;; // June parameters[2] = new ParameterValue; parameters[2].Name = &quot;ReportYear&quot;; parameters[2].Value = &quot;2004&quot;;

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(&quot;SessionID after call to Render: {0}&quot;,                rs.SessionHeaderValue.SessionId); Console.WriteLine(&quot;Execution date and time: {0}&quot;,               rs.SessionHeaderValue.ExecutionDateTime); Console.WriteLine(&quot;Is new execution: {0}&quot;,               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( &quot;report.mhtml&quot;, result.Length ); Console.WriteLine( &quot;File created.&quot; ); stream.Write( result, 0, result.Length ); Console.WriteLine( &quot;Result written to the file.&quot; ); stream.Close; }       catch ( Exception e ) {           Console.WriteLine( e.Message ); }   } } 

The &quot;ReportingService.CreateDataDrivenSubscription Method&quot; topic
The &quot;ReportingService.CreateDataDrivenSubscription Method&quot; 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 &quot;Example&quot; 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  with name of the namespace of the Reporting Services Web service. Typically,  is replaced with the name of the project. Replace  with the name of the Web Reference that corresponds to the Reporting Services Web service, and replace   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 = &quot;/SampleReports/Employee Sales Summary&quot; Dim description As String = &quot;My new data driven subscription&quot; ' Set the extension setting as report server email. Dim settings As New ExtensionSettings settings.Extension = &quot;Report Server Email&quot; ' Set the extension parameter values. Dim extensionParams(7) As ParameterValueOrFieldReference Dim [to] As New ParameterFieldReference ' Data-driven. [to].ParameterName = &quot;TO&quot; [to].FieldAlias = &quot;EmailAddress&quot; extensionParams(0) = [to] Dim replyTo As New ParameterValue replyTo.Name = &quot;ReplyTo&quot; replyTo.Value = &quot;dank@adventure-works.com&quot; extensionParams(1) = replyTo Dim includeReport As New ParameterValue includeReport.Name = &quot;IncludeReport&quot; includeReport.Value = &quot;False&quot; extensionParams(2) = includeReport Dim renderFormat As New ParameterValue renderFormat.Name = &quot;RenderFormat&quot; renderFormat.Value = &quot;HTML4.0&quot; extensionParams(3) = renderFormat Dim priority As New ParameterValue priority.Name = &quot;Priority&quot; priority.Value = &quot;NORMAL&quot; extensionParams(4) = priority Dim subject As New ParameterValue subject.Name = &quot;Subject&quot; subject.Value = &quot;Your sales report&quot; extensionParams(5) = subject Dim comment As New ParameterValue comment.Name = &quot;Comment&quot; comment.Value = &quot;Here is the link to your report.&quot; extensionParams(6) = comment Dim includeLink As New ParameterValue includeLink.Name = &quot;IncludeLink&quot; includeLink.Value = &quot;True&quot; extensionParams(7) = includeLink settings.ParameterValues = extensionParams ' Create the data source for the delivery query. Dim delivery As New DataSource delivery.Name = &quot;&quot; Dim dataSourceDefinition As New DataSourceDefinition dataSourceDefinition.ConnectString = &quot;data source=(local);initial catalog=Employee&quot; dataSourceDefinition.CredentialRetrieval = CredentialRetrievalEnum.Store dataSourceDefinition.Enabled = True dataSourceDefinition.EnabledSpecified = True dataSourceDefinition.Extension = &quot;SQL&quot; dataSourceDefinition.ImpersonateUserSpecified = False dataSourceDefinition.UserName = &quot;sa&quot; dataSourceDefinition.Password = &quot;saPassword&quot; delivery.Item = dataSourceDefinition ' Create the fields list. Dim fieldsList(1) As Field fieldsList(0) = New Field fieldsList(0).Name = &quot;EmailAddress&quot; fieldsList(0).Alias = &quot;EmailAddress&quot; fieldsList(1) = New Field fieldsList(1).Name = &quot;EmpID&quot; fieldsList(1).Alias = &quot;EmpID&quot; ' 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 = &quot;Select * from MailList&quot; queryDefinition.CommandType = &quot;Text&quot; 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 = &quot;TimedSubscription&quot; Dim matchData As String = &quot;<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>&quot; ' Set the report parameter values. Dim parameters(2) As ParameterValueOrFieldReference Dim empID As New ParameterFieldReference ' Data-driven. empID.ParameterName = &quot;EmpID&quot; empID.FieldAlias = &quot;EmpID&quot; parameters(0) = empID Dim reportYear As New ParameterValue reportYear.Name = &quot;ReportYear&quot; reportYear.Value = &quot;2004&quot; parameters(1) = reportYear Dim reportMonth As New ParameterValue reportMonth.Name = &quot;ReportMonth&quot; reportMonth.Value = &quot;6&quot; ' 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 = &quot;/SampleReports/Employee Sales Summary&quot;; string description = &quot;My new data driven subscription&quot;;

// Set the extension setting as report server email. ExtensionSettings settings = new ExtensionSettings; settings.Extension = &quot;Report Server Email&quot;;

// Set the extension parameter values. ParameterValueOrFieldReference[] extensionParams = new ParameterValueOrFieldReference[8];

ParameterFieldReference to = new ParameterFieldReference; // Data-driven. to.ParameterName = &quot;TO&quot;; to.FieldAlias = &quot;EmailAddress&quot;; extensionParams[0] = to;

ParameterValue replyTo = new ParameterValue; replyTo.Name = &quot;ReplyTo&quot;; replyTo.Value =&quot;dank@adventure-works.com&quot;; extensionParams[1] = replyTo;

ParameterValue includeReport = new ParameterValue; includeReport.Name = &quot;IncludeReport&quot;; includeReport.Value = &quot;False&quot;; extensionParams[2] = includeReport;

ParameterValue renderFormat = new ParameterValue; renderFormat.Name = &quot;RenderFormat&quot;; renderFormat.Value = &quot;HTML4.0&quot;; extensionParams[3] = renderFormat;

ParameterValue priority = new ParameterValue; priority.Name = &quot;Priority&quot;; priority.Value = &quot;NORMAL&quot;; extensionParams[4] = priority;

ParameterValue subject = new ParameterValue; subject.Name = &quot;Subject&quot;; subject.Value = &quot;Your sales report&quot;; extensionParams[5] = subject;

ParameterValue comment = new ParameterValue; comment.Name = &quot;Comment&quot;; comment.Value = &quot;Here is the link to your report.&quot;; extensionParams[6] = comment;

ParameterValue includeLink = new ParameterValue; includeLink.Name = &quot;IncludeLink&quot;; includeLink.Value = &quot;True&quot;; extensionParams[7] = includeLink;

settings.ParameterValues = extensionParams;

// Create the data source for the delivery query. DataSource delivery = new DataSource; delivery.Name = &quot;&quot;; DataSourceDefinition dataSourceDefinition = new DataSourceDefinition; dataSourceDefinition.ConnectString = &quot;data source=(local);initial catalog=Employee&quot;; dataSourceDefinition.CredentialRetrieval = CredentialRetrievalEnum.Store; dataSourceDefinition.Enabled = true; dataSourceDefinition.EnabledSpecified = true; dataSourceDefinition.Extension = &quot;SQL&quot;; dataSourceDefinition.ImpersonateUserSpecified = false; dataSourceDefinition.UserName = &quot;sa&quot;; dataSourceDefinition.Password = &quot;saPassword&quot;; delivery.Item = dataSourceDefinition;

// Create the fields list. Field[] fieldsList = new Field[2]; fieldsList[0] = new Field; fieldsList[0].Name = &quot;EmailAddress&quot;; fieldsList[0].Alias = &quot;EmailAddress&quot;; fieldsList[1] = new Field; fieldsList[1].Name = &quot;EmpID&quot;; fieldsList[1].Alias = &quot;EmpID&quot;;

// 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 = &quot;Select * from MailList&quot;; queryDefinition.CommandType = &quot;Text&quot;; 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 = &quot;TimedSubscription&quot;; string matchData = &quot;<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>&quot;;

// Set the report parameter values. ParameterValueOrFieldReference[] parameters = new ParameterValueOrFieldReference[3];

ParameterFieldReference empID = new ParameterFieldReference; // Data-driven. empID.ParameterName = &quot;EmpID&quot;; empID.FieldAlias = &quot;EmpID&quot;; parameters[0] = empID;

ParameterValue reportYear = new ParameterValue; reportYear.Name = &quot;ReportYear&quot;; reportYear.Value = &quot;2004&quot;; parameters[1] = reportYear;

ParameterValue reportMonth = new ParameterValue; reportMonth.Name = &quot;ReportMonth&quot;; reportMonth.Value = &quot;6&quot;; // 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); }   } } </li></ul>

The &quot;ReportingService.CreateReportHistorySnapshot Method&quot; topic
The &quot;Remarks&quot; section of the &quot;ReportingService.CreateReportHistorySnapshot Method&quot; 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.

<div class="references_section">