I'm using C# with ASP.NET(2.5) and SQL Server 2005.
I have an SSRS 2005 Report (*.rdl) stored in a varbinary field in the database, and I need to generate a report (in PDF or image file) and send it by e-mail, with some parameters. The CRUD part is OK, but I can't generate the report and export to PDF from an XML string (that I get from the varbinary field).
I don't have any code to give to you folks (sorry). I tried lots of tutorials from the web and none of them suited for me. I also searched here in stack overflow and didn't find anything.
Note 1: I know how to do it from a file stored in a hard drive, for example. I don't want to save the file I get from the varbinary field in the hard drive and generate the report from it. I want to generate the report from the XML string stored in a variable.
Note 2: I'm new to C#, and have another silly question: Crystal Report (.rpt) and SSRS (.rdl) are different files (different XML structures), right?
Firstly, in answer to Note 2, Crystal Reports and SSRS are competitors, so yes, the formats are different.
Secondly, you want to use the ReportExecutionService class. If you have any report parameters to set, use SetExecutionParameters() and Render() with Format=PDF.
Related
I am looking at using SSRS for some reporting.
I want to have a C# console program that runs the SSRS report.
The C# program will save an exported PDF file locally.
The C# program will run locally.
The SSRS report is on another computer on the same domain. All users can access this via a UNC path.
The C# program will run some calculations on some raw database data, and the results will be the dataset that the SSRS report uses for its charts and tables.
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.
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.
I am using SQL Server Reporting Service 2005(SSRS 2005) to export report to Excel and PDF and VS2008. But now i want an option to Export to Word also, but it is not possible in SSRS 2005 report that i came to know after googling. Here problem is that I CAN'T USE SSRS 2008 REPORT. So i thought that i will follow the steps as....
-- Export to Word
1. Export to PDF
2. Convert that PDF to Word document
Even after so much of googling i didn't got the proper answer. I told once and even telling that i can't use any third party tools so don't give me wrong path.
There are many fundamental differences between PDF and Word making the approach you want highly undesirable as a general workflow. I'll give just one example: PDF typically does not store information about document structure - sentences, paragraphs, columns, tables... All it stores is the actual text at certain locations at a page. Word of course does have those concepts.
Is it possible to do what you want? Yes, to some extent. In the general case with guesswork and approximation. If you know which information you want to convert it might be possible to search for it in the PDF file generated by SSRS and then generate a Word file out of it. However, if SSRS allows export to text, XML, RTF or any other structure based file format (however slightly structure based), you'd have a much easier time.
If you insist on doing what you suggest here, you would have to:
1) Write code to take the PDF exported from SSRS and interpret it (find the textual content you want)
2) Recreate the necessary structural information from that information (what are paragraphs, where and what are the tables, what's the formatting etc...)
3) Write that into a file Word can read (or create a new Word document directly using automation).
This would be a considerable amount of work, but you have all of the necessary information as the PDF specification is freely downloadable from the Adobe web site and it contains all of the information you need.
I am converting an MS Access 2003 application to C# (VS 2010) and SQL Server 2008.
It's all pretty basic except for one thing. I've got embedded excel spreadsheets in the application. In Access they are edited and saved as OLE DB objects. The spreadsheet is then displayed as an image in the report. I have converted the Access Reports to Crystal Reports and converted data shows just fine in the reports.
I can create the spreadsheet and save it to a file, but what I can't figure out is how to create and save an Excel Spreadsheet as an image in my SQL Server field so Crystal can put it in the report.
I also know images are deprecated in SS 2008 so any ideas on how to move my whole report to something else would be appreciated.
FYI: An older post suggested Lenni Lobel's articles, but they are not there anymore.
Sounds like there are two requirements here:
Be able to access the file data via Crystal
Be able to efficiently store a spreadsheet in a SQL Server 2012 database column.
Your choices (other than Image columns) would appear to be FileStream and VarBinary. Here's a comparison: VARBINARY vs. FILESTREAM.
I can't comment on Crystal's ability to access either of those, unfortunately.
You can use OLE object in Crystal reports to show the excel file (without saving it as a picture) This will probably work fine for all computers where Excel is installed.
I am working in visual 2008 with sql server 2005 as the back end. I am trying to create a crystal report with xsd file.This is what i did.
I created an empty xsd file from "Add New Items".i dragged the stored proc from the server explorer from the database which i want to attach to the crystal on to the xsd.
Created an empty crystal report,attached the xsd file on to the report through "Make new connection" and selected the fields which i want to display in the report.
Now when i do the print preview of the report is shows me the junk data and not the actual data that stored procedure returns.? I cant understand this behaviour.
Am i missing something?
Thats Crystal Reports for you. What you are describing is typical behaviour do not be alarmed. I have written a number of reports specifying a .xml or .xsd document as the data type(You need to remember to select ADO.NET from add connections for the following to work). When I go to run the report I simply specify the actual datatable that I get from SqlServer/Oracle/etc by doing the following
report.Database.Tables[0].SetDataSource(dataTable);
Like you in the preview pane I get bogus values even though my xml file may contain actual data along with the schema but when I actually run the Crystal Report I get the expected out put.
I need to create reports in a C# .NET Windows app. I've got an SQL Server 2005 .I want to display two more field to report(not available in data base table. I want to create these field by adding some data from existing field of data base table)
If you look at the .NET API exposed by Crystal Reports, you'll find that you can inject a DataSet into a report - this gives your application full control over the data used by the report, leveraging Crystal Reports as a presentation engine.
I've used this technique to generate reports over data soures not natively supported by Crystal Reports - it also helps to ensure that all the data comes from the sames source (as the API for changing the connection used within a normal Crystal report is somewhat flakey).
So, what I'd do in your situation is to load all the required data into a DataSet, add the extra columns, and then pass the dataset into the report. Only complex bit is that you need to save out the XML schema of the dataset and import it into Crystal Reports so that it is aware of the shape of your data.
You could use a crystal function also for this. Depending on how complex the calculation is from Column A to B. The more complex the easier it becomes just to do what Bevan says and change the dataset.
If you were more specific i might be able to give you some example code.
Use CR formula field.