Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
RenderStream Method
Collapse the table of content
Expand the table of content

RenderStream Method

SQL Server 2000

ReportingService.RenderStream Method

Returns a stream that is associated with a rendered report. Examples of streams include images and charts.

Public Function RenderStream( _
   ByVal Report As String _
   ByVal DeviceInfo As String _
   ByVal StreamID As String _
   ByVal HistoryID As String _
   ByVal Parameters() As [Namespace].ParameterValue _
   ByRef Encoding As String _
   ByRef MimeType As String _
) As Byte()
   Member of [Namespace].ReportingService

public System.Byte[] RenderStream(
   string Report,
   string DeviceInfo,
   string StreamID,
   string HistoryID, 
   [Namespace].ParameterValue[] Parameters,
   out string Encoding, 
   out string MimeType
   Member of [Namespace].ReportingService
The full path name of the report.
The device-specific content used by the rendering extension.
The stream identifier.
Optional. The unique identifier of the report history snapshot for which to retrieve the stream. The identifier is based on the date and time the report history was created. You can omit this parameter if the rendered report is not a report history snapshot.
Optional. An array of ParameterValue[] objects that represent the report-specific parameters.
[out] The encoding used to render the content of the report.
[out] The MIME type of the stream.
Return Value

A Byte[] array of the requested stream. For more information about this data type, see "Byte Structure" in the .NET Framework documentation.


Operation Description
Read Properties Required on the report and any corresponding subreports.
Execute and View Required on the report and any corresponding subreports.


The SessionId is automatically preserved in the SessionHeader between calls through the same proxy object. You must clear the SessionHeader, if you do not want to preserve the session or would like to start a different session. For more information, see SessionHeader Class.

If you are rendering a report with External images (meaning that the images are stored as items in the report server database), you do not need to call RenderStream when rendering a report to HTML 4.0 using the Render method. In this case, you must render the report with the device information setting HTMLFragment set to true. The report server automatically constructs the URLs with the appropriate GUID reference for each secondary image stream. This is the easiest way in which to render a report to HTML 4.0 using the SOAP API. You need to ensure that you give your users access to the virtual location to the images on the report server. For more information about External images, see Adding an Image.


To execute the following code example, you must reference the Reporting Services WSDL and import certain namespaces. The following code example uses the StreamRoot device information setting to reference the image URLs of secondary streams in your Web application and then renders a report to the HTML 4.0 output format. The sample then demonstrates how to render each of the secondary image streams using the RenderStream method so that they can be referenced by a report written to a Web page (ASP.NET Web Form):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   Dim rs As New ReportingService

   rs.Credentials = System.Net.CredentialCache.DefaultCredentials

   Dim results As Byte(), image As Byte()
   Dim streamids As String(), streamid As String

   ' Render the report to HTML4.0
   results = rs.Render("/SampleReports/Product Line Sales", "HTML4.0", _
   Nothing, "<DeviceInfo><StreamRoot>/WebApplication1/</StreamRoot></DeviceInfo>", Nothing, _
   Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, streamids)

   ' For each image stream returned by the call to render,
   ' render the stream and save it to the application root
   For Each streamid In streamids
      image = rs.RenderStream("/SampleReports/Product Line Sales", "HTML4.0", streamid, _
      Nothing, Nothing, Nothing, Nothing, Nothing)

      Dim stream As System.IO.FileStream = _
      System.IO.File.OpenWrite("C:\Inetpub\wwwroot\WebApplication1\" & streamid)

      stream.Write(image, 0, CInt(image.Length))
   ' Write the rendered report to the Web form

End Sub

private void Page_Load(object sender, System.EventArgs e)
   ReportingService rs = new ReportingService();
   rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

   byte[] result;
   byte[] image;
   string[] streamIDs;
   string optionalString = null;
   ParameterValue[] optionalParams = null;
   Warning[] optionalWarnings = null;

   // Render the report to HTML4.0
   result = rs.Render("/SampleReports/Product Line Sales", "HTML4.0", null,
      null, null, null, out optionalString, out optionalString, out optionalParams,
      out optionalWarnings, out streamIDs);

   // For each image stream returned by the call to render,
   // render the stream and save it to the application root
   foreach (string streamID in streamIDs)
      image = rs.RenderStream("/SampleReports/Product Line Sales", "HTML4.0", streamID,
         null, null, null, out optionalString, out optionalString);

      FileStream stream = File.OpenWrite(@"C:\Inetpub\wwwroot\WebApplication1\" + streamID);
      stream.Write(image, 0, image.Length);

   // Write the rendered report to the Web form

See Also

ReportingService Class

Reporting Services Web Service Library

© 2015 Microsoft