Using subreports with Microsoft's ReportViewer control in local mode - reportviewer

Does anyone have a recommendation for an excellent reference on Microsoft's ReportViewer (VS 2008 flavour) when used in local mode? I'm currently using it but parts of it are a bit of a black box so I'd like to read up on the entire subject.
Especially want to start using sub-reports to display more complex parent-child reports. I'm assuming they work in a similar mode to Crystal Reports with which I'm reasonably familar.
Thanks, Rob.

The link to http://www.gotreportviewer.com is a good once but it does look like material on local sub reports and ReportViewer 2008 is a little sparse and spreadout across the net. It would be a subject worth blogging about so I will :-)
Here are a few headlines:
A subreport is a completely separate report but is linked to the master report using the standard report parameter mechanism. The master report is configured to pass one or more of it's fields (e.g. the primary key) to the subreport. The subreport typically then uses this parameter as a parameter to it's own query to load a dataset
Even though you may have defined a data source against the subreport when designing it, this isn't used when used in a master report. Instead you have to implement a handler for the SubreportProcessing event. The same handler is called for each subreport you add to your master report so you can query the parameters passed to the handler to determine the dataset to load.
The event handler is called once for each record in master report. For example, if the master report displays 200 records, the event handler is called 200 times but with a different parameter each time.
Because of this, you have to be wary of performance. The first report I ran had 2,000 records (perfectly okay for a flat report) but each of those 2,000 records fetched 20 child records for the subreport. It did run but took several minutes before the report was rendered
If you can structure your data so that a single dataset can be used containing data for both the master and subreport, then nested data regions have better performance - only one query to return 2,000 records not 2,000 individual queries. See http://www.gotreportviewer.com/masterdetail/index.html
Cheers, Rob.

I worked with the ReportViewer control at one point and was able to find some good information at http://www.gotreportviewer.com

Was the documentation insufficient? In what way?
Reporting Services and ReportViewer Controls in Visual Studio
Samples and Walkthroughs
ReportViewer Controls (Visual Studio)

Related

Error with nested crystal reports **Not supported within subreports**

I have a vb.net solution that is developped using vs 2010 and .net framework 4.0.
On a submit button reports are generated using Crystal Reports version 13.0.2. Reports are filled with datasets and some of them are nested reports.
Suppose I have report A, with sub-report B and B contains a sub-report C. I am using the below code to fill data:
MainReport.Load(Server.MapPath("~\Reports\A.rpt"))
MainReport.OpenSubreport("B.rpt").SetDataSource(DsB)
MainReport.OpenSubreport("B.rpt").OpenSubreport("C.rpt").SetDataSource(DsC)
But the third line is throwing an error
Not supported within subreports.
What is the error here? Any suggestions?
Please note that I am not using parameters in subreports.
Nested subreports are not supported in Crystal Reports. This is by design.
See also the following discussions:
https://archive.sap.com/discussions/thread/3348939
https://archive.sap.com/discussions/thread/2142327
http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=193
You'll need to re-design your report(s).
MatSnow precisely made clear what is the error.
As a suggestion, the workaround i usually do is to combine groups and details sections.
I cannot say t is always possible, but the main idea would be to use a group section to show the data of A, use the details section to show the data of B, and use a subreport to show the data of C.
Of course, if your current subreports contains groups, you will have to create more groups.
Another advantage of this approach is because subreports are slow. But it is a problem only for large reports.

SSRS 2005 Subscription changes

OK this is my question(s) and its SSRS 2005 and SQL Server 2005/2008
I had been tasked with rebuilding a dozen or so reports that our users use on their data systems. We just build them and since every DB instance is schematically the same for all our clients, we push the reports out to their report servers for use.
So modified a great many reports, but the reports have blown away the clients subscriptions. So every user that uses these reports, that can be a great many seeing as how everyone can have their own set of parameters, has to run the reports manually or redo their subscriptions.
My company would very much like to avoid that, but I can not figure out how to change a report, and even with the same parameter set going in as the last report, keep the subscription there.
Even when I copy the report down to their report server and replace the old with the new using same name. The subscription is still there, but it gets modified.
I am looking either for a way to push down a subscription as part of the report, so that they will have minimal input to their subscriptions in order to tailor it to their needs
--OR ideally--
Upload a new version of the report to their report server and just have the subscription apply to the newest report that I have put on their server
It doesn't really matter which one but the second is best seeing as how individual users use the reports with individual names as a parameter
Many thanks in advance for anyone that can point me to the way to manage out subscriptions on my side, or enable my reports to assume the subscriptions of same named reports on their server.
--edit--
Want to put a clearer picture out there
I have a master copy of a report. The users use the report on their own systems.
I do some heavy modifications to the master copy of the report, and upload it to their systems. using the same name and same parameter set as the original report.
I want the subscriptions on their report server to find this report using the same name.
so XXX.report has a subscription. I change it to XXX.report locally, and upload to their servers. The subscriptions are not synching though.
Thanks
I'm not sure how you're accessing SSRS but you can use the following webservice methods to download and upload report subscriptions
ListSubscriptions
GetSubscriptionProperties
GetDataDrivenSubscriptionProperties
DeleteSubscription
CreateDataDrivenSubscription
CreateSubscription
Using those methods, you use ListSubscriptions to get a report's subcriptions. The Subscription.IsDataDriven property will tell you if it's data driven or not. For data driven subscriptions, use GetDataDrivenSubscriptionProperites to get the subscription properties, otherwise use GetSubscriptionProperties. All of those classes are XML serializable so you can save them to disk out of the box using the XmlSerializer.
To readd the subscriptions, use DeleteSubscription to delete the subcriptions one by one and then CreateSubscription or CreateDataDrivenSubscription to readd the subscriptions.
This is a hack though, because you should be able to modify reports without breaking the subscriptions. You should to the following to help diagnose the issue
Set SSRS logging to verbose for all components
Use the click once report builder to change the title of a report and see if the subscriptions break when you click save
Have the SQL profiler running on the ReportServer database to see what SQL is being generated when the subscriptions break
there's a tool called Reporting Services Scripter from Jasper Smith. I think it should work for you.
What I had to wind up doing was going back and change all the input parameters, including the sql content for the drop downs, back to what they originally were. Then playing with the SQL for the report to accept the new(old) parameters.
Thanks for your input. I accepted the web services answer as that is a path I will have to explore for our next update.

Crystal Reports vs. SQL Queries

I'm a programmer (mostly C++) who has moved into a non-software workplace. However, I don't have much experience with database stuff at all.
TL;DR: If we compare Crystal Reports to just writing scripts that execute SQL queries and parse the results, is there anything that CR can do that isn't possible via SQL queries & scripts? I'm talking purely in terms of extracting data - not making pretty documents.
Detail:
At my workplace they have a process where you run a bunch of Crystal Reports, modify the date range to the current month, manually export each to excel, delete the rows and columns that aren't needed, and then cut and paste into a summary excel document that is used by management.
To me, this is pretty crazy and stupid. I'd like to automate/script most of it.
So I have two options:
Learn Crystal Reports and try to modify the existing reports to be more automated.
Dump CR and just learn SQL and do the whole thing programmatically with scripts working with CSV files or something.
I'd much rather learn SQL since it's more general and useful. But I need to be assured that I can get the data output that I need (without writing a million lines of code to reproduce CR myself.)
So yeah, I'm looking for an answer like, "The two are equivalent. Anything you can do in CR you can do easily via scripts and SQL," or "If you need to group records into categories based on a parameter and then sum their one of their fields, then CR will do it much more easily than raw code," to push me in one direction or another.
Edit:
Some additional detail. At the moment my crystal reports run a database query, and then crystal does things like, "don't display the records that are returned, instead group the records by Field A and then display the count of how many records in each group."
Is functionality like this difficult to reproduce via SQL coding? I wouldnt want to have to write a python (or whatever) script to parse and manipulate the data from plaintext CSV, for example.
You can't just compare SQL and CR - they have different purpose. SQL (in this context) is data source, CR is pretty output formatter. For excel you would need data, not formatted output. Excel combined with SQL can give you all CR options (dynamic crosstab reports, charts etc) what you can't get directly from SQL data.
BTW, creating SQL views or procedures is often needed to overcome CR limitations; from this standpoint SQL has lot of more options than CR.
I personally would go with SQL+Excel route. In our company we're using simply SQL+CR without postprocessing, sometimes SQL+Excel. Our customers are using different approaches.
But like said by other people, choice of tools depends on more things. Who has to redesign reports? Who will maintain these reports? How often requirements change? Are there more uses for CR reports besides sourcing Excel tables? Who will be waked up at night, if reports do not work?
Management perpective:
In many I will say mostly cases management does not know SQL. So if a manager for E.g.HR wants to know staus about something then how he will get that status?? This is where Crystal reports come into picture, Using crystal reports they do not have to worry about SQL; they will just enter required fields and get their data.
Programmer perspective:
Simple data outputs can be achieved through SQL but consider a scenario where you need to pull details as well as summary. I agree it can be done via SQL but consider the overhead of time and proficiency required to develop such output using sql. I bet it wont be that easy to develop such output using sql as compared to crystal. So I will say learn both SQL and crystal, you will get to choose the tool to apply for your requirement.
You can write SQL and drop it into the Crystal Report. Best of both worlds, and possibly faster performance than the drag-and-drop Crystal functionality.
You will see some response time lag when the report runs.
There are actually a few things that Crystal Reports can do that are very tricky using plain SQL Queries as Crystal Reports can access the entire dataset in a single formula and can do things at runtime.
However unless you have some really crazy complex Crystal Reports I would recommend building a tool in Excel that can one click the info straight into a new sheet.
I did this and it got me a promotion, not kidding :P
I have a custom Excel Addin I can give you code to that basically does this:
On open, connects to the database and downloads a list of menu options connected to views and procedures
Adds these menu options into a new Ribbon tab within Excel
When one is clicked, runs the view and dumps the entire dataset (properly formatted) into a new sheet
Advantage of this is you can update the main menu list and each view it references without making any changes to the file or re-issuing anything to everyone.
Crystal could be helpful if you want to create a document with a specific layout , logos etc. and show some data on it. Export to excel from Crystal repot is not easy - usually there are a lot of empty columns and rows and each report should be tweaked to avoid that.
If you need to export some data from a SQLServer database to excel your best option will be SSIS ( I guess you have a license for SQL Server). If you don't have license for SSIS or you are using for example Access database there are also some inexpensive tools, which can retrieve data from any database ( not just SQLServer) and export it to excel. I would suggest you to check this one: http://www.r-tag.com. It can run Crystal reports and SQL reports so you can start using your crystal reports immediately and start transforming them to SQL reports whenever you have time for that. Both reports could be exported to excel.
i fixed this by editing excel sql, Left(Column_maxLength, 250)
this resolved my issue
in my case if even if i read left 250 character is enough

Dynamically generating reports in Pentaho and dealing with report definitions store in the database

I am developing a reporting application where a user can select(and order) reports from a list of 100 reports and ask for a master report. This master report will contain all the selected reports in the exact order and with a table of contents listing the reports included in the master report. The reports available for the user to select (which could be 100s) are stored in the database.
My questions are :-
To generate the master report with the user selected reports, the only solution I can see is using the Reporting Engine API to generate a dynamic report into which I have to add the user selected reports as subreports. Is this the right and easiest way to approach this problem? Does anyone have samples of the Reporting Engine API usage especially to inject subreports in a Master report?
Since I am storing the reports in the db(blobs), I am trying to find a way to generate my sub reports with an inputstream rather than a URL as specified in ResourceManager.createDirectly(url, MasterReport.class), but haven't been successful till now. How can I generate reports from definitions stored in the database? There should be some resource abstraction.
Read your reports into a byte-array and then use the ResourceManager.createDirectly method as usual. That will solve your problem of parsing the reports.
You can parse them directly into SubReports by using
ResourceManager.createDirectly(bytes, SubReport.class)
These subreports can then be added to your master report as banded subreports. if you want your selected reports to start on a new page, make sure you set the "pagebreak-before" style on your subreport's report-header.
There is a resource abstraction: It is called "LibLoader" and you can create your own ResourceLoaders that deal with the problem of getting your data out of your database as raw-streams so that the ResourceFactory implementations can interpret/parse the raw-data.
But every database is designed differently and thus you as the system integrator have to write the glue code for it. We only can offer the interfaces.

Reporting Services: Exported to Excel results are different than the ones viewed on IE

I'm having this problem:
The SQL Server holds a said value, let's say 990.30, the Reporting Services Report show a different value (948.33) when viewed online, in the brower and a third value (912.22) when the report is exported to Excel.
There are no formulas on Excel, just plain values.
Also, there's no formula on the layout of the report.
The code shows only a simple select that, when run on the SQL Server Management Studio, returns me the original value (990.30).
How on earth shall I start to troubleshoot this ?
I've never heard of this kind of problem before. I would recommend submitting a ticket to Microsoft and provide them with screen shots of the errors, the RDL file, a sample output of the stored procedure, etc.
To troubleshoot this on your own, I would recommend creating a new report that just has a simple table that returns all the details from your stored procedure or query to validate the values are consisten across all interfaces. From there, just start adding on complexity until you get the report to look like it is today.