Data Cogs Information Technology

posts - 131, comments - 251, trackbacks - 36

General

Search This Site

Powered by Google

Brisbane

Locations of visitors to this page

Information

Archives

Images

Blogs

CV etc.

Links For Me

Since I gave a Crystal Report tip earlier, I thought I better balance this with a Reporting Services tip.  This uses the Reporting Services web service (reportservice.asmx) to download a report as a PDF and open it directly in Acrobat Reader on a Winforms client.

//////////////////////////////////////////////////

ReportingService.ReportingService rs = new ReportingService.ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
     
// Render arguments
byte[] result = null;
string format = "PDF";
string historyID = null;
string devInfo = null;

parameters = new ReportingService.ParameterValue[1];
parameters[0] = new ReportingService.ParameterValue();
parameters[0].Name = "SelectedTable";
parameters[0].Value = selectedTable;
   
ReportingService.DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
ReportingService.Warning[] warnings = null;
ReportingService.ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
ReportingService.SessionHeader sh = new ReportingService.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);
 string filename = "";
    
 FileStream stream = File.Create(filename, result.Length);
 stream.Write(result, 0, result.Length);
 stream.Close();
 System.Diagnostics.Process.Start(filename);
}
catch (System.Web.Services.Protocols.SoapException e)
{
 System.Windows.Forms.MessageBox.Show(e.Message);
}
///////////////////////////////////////////////////////

posted on Wednesday, October 06, 2004 2:54 PM

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Url
Comment   
Protected by Clearscreen.SharpHIPEnter the code you see: