From: Azmi on
How can I read the URL line in the SSRS code. Please help



IfThenElse wrote:

Thank you for sharing this code.
26-Oct-07

Thank you for sharing this code.
That will help once I write against 2005
Some of the code I still do not understand, I hope to find explanations by
line item

Thanks again

Previous Posts In This Thread:

On Thursday, October 25, 2007 6:34 PM
IfThenElse wrote:

How to Programatically get a Report in PDF format from SSRS
Hi,

I have a report with parameters and need to get it via C# in PDF Format.

Need an example that works.

Thank you,

On Thursday, October 25, 2007 6:37 PM
IfThenElse wrote:

Re: How to Programatically get a Report in PDF format from SSRS
In Addition I am using SQL 2000 NOT 2005

On Thursday, October 25, 2007 7:29 PM
Norman Yuan wrote:

Call Reporting Services' web services.
Call Reporting Services' web services. There is a method called Render(),
that returns report in certain formt (PDF,HTML...) as binary stream. Simply
save the sttream to disk or send it back to user's browser (if the calls is
made via web application).


"IfThenElse" <sql_agentman(a)hotmail.com> wrote in message
news:ejZ3Pe1FIHA.4772(a)TK2MSFTNGP02.phx.gbl...

On Thursday, October 25, 2007 9:17 PM
EMartinez wrote:

Re: How to Programatically get a Report in PDF format from SSRS
On Oct 25, 5:34 pm, "IfThenElse" <sql_agent...(a)hotmail.com> wrote:


Here's an example. It's a snippet from a web method I wrote to call
and export an SSRS report programmatically. In this example, I
declared a web reference named 'SSRSExecutionSvc' that points to the
report server's wsdl file.

Byte[] result = null;
String strReportPath = "", strFormat = "", strDeviceInfo =
"", strEncoding = "",
strMimeType = "", strExt = "", strSessionId = "",
strInvoicePath = "";
String strHistoryID = null;
String[] strStreamIDs = null;

strInvoicePath =
ConfigurationManager.AppSettings["InvoicePath"].ToString();

SSRSExecutionSvc.ReportExecutionService rs = new
SSRSExecutionSvc.ReportExecutionService();
//If you explicitly define a user below instead of the
default used here, you will need to make sure that the user account
has, at a minimum, Browser rights in the Report Manager.
rs.Credentials =
System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://ServerName/reportserver/
ReportExecution2005.asmx";

// Render arguments
strReportPath = "/Reports Directory/ReportName";
strFormat = "PDF";
strDeviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></
DeviceInfo>";

// Prepare report parameter.
SSRSExecutionSvc.ParameterValue[] parameters = new
SSRSExecutionSvc.ParameterValue[1];

parameters[0] = new SSRSExecutionSvc.ParameterValue();
parameters[0].Name = "ORDERID";
parameters[0].Value = OrderID.ToString();

SSRSExecutionSvc.Warning[] warnings = null;

SSRSExecutionSvc.ExecutionInfo execInfo = new
SSRSExecutionSvc.ExecutionInfo();
SSRSExecutionSvc.ExecutionHeader execHeader = new
SSRSExecutionSvc.ExecutionHeader();

rs.ExecutionHeaderValue = execHeader;

execInfo = rs.LoadReport(strReportPath, strHistoryID);

rs.SetExecutionParameters(parameters, "en-us");
strSessionId = rs.ExecutionHeaderValue.ExecutionID;

try
{
result = rs.Render(strFormat, strDeviceInfo, out
strExt, out strEncoding, out strMimeType, out warnings, out
strStreamIDs);

execInfo = rs.GetExecutionInfo();
}
catch (SoapException SoapEx)
{
return SoapEx.Detail.OuterXml.ToString();
}

// Write the Contents of the Invoice to a PDF Document.
try
{
FileStream stream = File.Create((strInvoicePath +
"Order " + OrderID.ToString() + " Invoice.pdf"), result.Length);
stream.Write(result, 0, result.Length);
stream.Close();
}
catch (Exception Ex)
{
return Ex.Message;
}

This was created in C# 2005 (ASP.NET 2.0) as a Web Method for SSRS
2005. I'm not sure if this functionality is also available in SSRS
2000; however, it's worth a try. Hope this helps.

Regards,

Enrique Martinez
Sr. Software Consultant

On Friday, October 26, 2007 9:40 AM
Bruce L-C [MVP] wrote:

Several sent posts to you about webservices.
Several sent posts to you about webservices. The other option is to embed an
IE control and then use URL integration (you just create the appropriate URL
string and set the property on the IE control). Search Books Online on the
web (RS 2000 books on line does not have as good a set of documentation on
URL integration as 2005 - url integration is the same for both versions so
the RS 2005 documentation will work for you).

With URL integration you have full control over the rendering format.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services


"IfThenElse" <sql_agentman(a)hotmail.com> wrote in message
news:ejZ3Pe1FIHA.4772(a)TK2MSFTNGP02.phx.gbl...

On Friday, October 26, 2007 11:00 AM
IfThenElse wrote:

Thanks everyone, I went the webservice method route.
Thanks everyone, I went the webservice method route.
the Problem I had was that one of the parameters name was not matching and
the Exception was generic that an internal error occurs.
So the example I was working with was correct.
Once I figured out where the SSRS logs are it pointed me to the right error
message.
The SSRS log files are important. I was fooled by looking into the SP
Parameters and not the Report Parameters I assumed they should match.
The developer made them different and out of sequence.

Thanks again,


"Bruce L-C [MVP]" <bruce_lcNOSPAM(a)hotmail.com> wrote in message
news:%23omsTX9FIHA.1208(a)TK2MSFTNGP05.phx.gbl...

On Friday, October 26, 2007 11:01 AM
IfThenElse wrote:

Thank you for sharing this code.
Thank you for sharing this code.
That will help once I write against 2005
Some of the code I still do not understand, I hope to find explanations by
line item

Thanks again


Submitted via EggHeadCafe - Software Developer Portal of Choice
BOOK REVIEW: Effective C#, Second Edition [Addison Wesley]
http://www.eggheadcafe.com/tutorials/aspnet/b2f8766d-a4c1-4d5a-97af-c38852b3b455/book-review-effective-c.aspx