We have been lately trying to get Reporting Services working with our SharePoint and so far it is playing nicely.
I have managed to get together a piece of code that will load a report template that is stored in SharePoint site and render the report in a browser. Well, I found the code in the description of the "Render" method in MSDN Documentations.
Here is a list of links that might be useful to read:
The below code is
You will have to add web references to the ReportExecution2005.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ReportingServiceWebServicesTest.CecilAdmin08ReportExecution2005;
namespace ReportingServiceWebServicesTest
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportExecutionService rs = new ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Render arguments
byte[] result = null;
string reportPath = "/reportingservices/Reports/Report1.rdl";
string format = "HTML4.0";
string historyID = null;
ParameterValue[] parameters = new ParameterValue[2];
string encoding;
string mimeType;
string extension;
Warning[] warnings = null;
string[] streamIDs = null;
ExecutionInfo execInfo = new ExecutionInfo();
ExecutionHeader execHeader = new ExecutionHeader();
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(reportPath, historyID);
parameters[0] = new ParameterValue();
parameters[0].Name = "param1";
parameters[0].Value = "2";
parameters[1] = new ParameterValue();
parameters[1].Name = "param2";
parameters[1].Value = "5";
rs.SetExecutionParameters(parameters, "en-us");
String SessionId = rs.ExecutionHeaderValue.ExecutionID;
result = rs.Render(format, null, out extension, out encoding, out mimeType, out warnings, out streamIDs);
Response.ClearContent();
Response.AppendHeader("content-length", result.Length.ToString());
//Response.ContentType = "application/pdf";
Response.BinaryWrite(result);
Response.Flush();
Response.Close();
}
}
}