user2023861
user2023861

Reputation: 8208

How do I run a SSRS report from C# using a C#-produced dataset and export a PDF file?

I am looking at using SSRS for some reporting.

I am having trouble figuring out how to set up a process to do this. What's the best way to access the report from a C# program? Using the full UNC path, using a service reference to the ReportService2010.asmx file, using a web reference to the ReportService2010.asmx file, or something else? How can I provide the SSRS report with a dataset to use for its charts and tables? How do I programmatically export a PDF file?

As you can tell, I'm very new to SSRS. The tutorials I've found online either go into too much depth, or not enough.

Upvotes: 0

Views: 4823

Answers (1)

kyzen
kyzen

Reputation: 1609

You need to either pull the report into your application in a reportviewer control in order to supply it with your dataset directly, or your C# program is going to need to insert the data into a database for the SSRS server to process it.

Fortunately, that's the hard part. Since the report is hosted on another server, you can easily access it directly, rendered in the PDF format you desire. Access the report via the ReportServer endpoint url (by default it'll be SSRSServerURL/ReportServer), and supply it with any necessary parameters, and the appropriate commands to render (&rs:Command=Render&rs:Format=PDF). For example:

http://SSRSNode001/ReportServer/Pages/ReportViewer.aspx?%2fSAMPLEFOLDER%2fSUBFOLDER%2fMYREPORT&PARAM1=123&PARAM2=321&rs:Command=Render&rs:Format=PDF

If you end up using a local reportviewer control, you should still be able to have the rendered produce a PDF output.

Upvotes: 1

Related Questions