Databases Reference
In-Depth Information
ReportingService rs = new ReportingService();
//set the credentials to be passed to Reporting Services
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
ParameterValue[] parameters = new ParameterValue[0];
string encoding;
string mimeType;
ParameterValue[] parametersUsed;
Warning[] warnings;
string[] streamIds;
//render the report
byte[] data;
data = rs.Render(path, format, null, null, parameters, null, null,
out encoding, out mimeType, out parametersUsed,
out warnings, out streamIds);
//determine if format is rendered to the web or a file.
string extension = GetExtension(mimeType);
string reportName = path.Substring(path.LastIndexOf(“/”) + 1);
string fileName = reportName + “.” + extension;
//write the report back to the Response object
Response.Clear();
Response.ContentType = mimeType;
//add the file name to the response if it is not a web browser format.
if(mimeType!=”text/html”)
Response.AddHeader(“Content-Disposition”, “attachment; filename=” +
fileName);
Response.BinaryWrite(data);
}
VB
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
'get the path and output format from the query string
Dim path As String = Request.Params(“Path”)
Dim format As String = Request.Params(“Format”)
'create the ReportingService object
Dim rs As New ReportingService
'set the credentials to be passed to Reporting Services
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim parameters As ParameterValue()
Dim encoding As String
Dim mimeType As String
Dim parametersUsed As ParameterValue()
Dim warnings As Warning()
Dim streamIds As String()
'render the report
Search WWH ::




Custom Search