Can crystal reports get data from an object data source? - crystal-reports

Can crystal reports get data from an object data source instead of a database? I am using the crystal reports that comes with vs2008. I am coding in c# 3.5.
I would like to use an object data source that returns a List< MyClass>.
For when we migrate to ssrs in the future, Can ssrs 2008 get data from this object data source ?

SetDataSource has an overload excepting ICollection parameters. Using it, you can bind simple collections of objects to CR. But this isn't that flexible than using data sets. With data sets you can bind multiple related tables and build reports of a higher complexity.
The migration of your server has no impact on CR, because SetDataSource only works with disconnected objects such as data sets or object data sources.

Yes you can do that, but you have to wrap the objects in an array :
// my crystal report
Rpt rpt = new Rpt();
AirLine lAirLine = (AirLine)cmbAirLine.SelectedItem;
// I added two objects as datasources in report designer
// here aWB.AWBPieceList is List<AWBPiece> where 'AWBPiece' is some class.
rpt.Database.Tables[0].SetDataSource( AWBPieceList.ToArray() );
// the second : objects are mapped to tables by crystal report.
rpt.Database.Tables[1].SetDataSource( new AirLine[] { lAirLine } );

Related

How to create a DataSet for RDLC reporting from a stored procedure "ObjectResult" using ADO.Net Entity Data Model

I'm trying to generate an ObjectResult as the DataSource for a ReportViewer. The report viewer is looking for a data table as the data source.
Is there an easy way to convert a stored procedure's ObjectResult for use as a RDLC data source?
The following is the current state of my code:
Created a utility to generate a DataSet from the generated list.

Use multiple data sources within a Jasper report

I have a Jasper server, which holds some reports. These reports I can access by the Rest interface (https, get). One of the reports should return some data from an Oracle database, where data are stored into multiple schemas. The schemas have an identical structure.
select * from schemaA.tableX
displays the data from schemaA. Now I have to change the report data source:
select * from schemaB.tableX
to display the data from schemaB (structure of tableX is the same as in schemaA). I would like to configure my report with a parameter, to switch between the schemas (there are a lot of such schemas into the database).
Is it possible to change the schema name within the report dynamically or can I change the datasource definition of the report using a report parameter? I would prevent n identical reports on the Jasper server which only differ in the datasource definition.
Thank you.

Call a sproc passing parameters from different sproc in Crystal Reports

I am writing some custom reports for some 3rd party software. The software provides stored procedures from which to get my data.
One of the new requirements for my report is to get the data for an order, then if there is an associated order, then run the same sproc using the associated order's data.
Basically:
Order #1 is associated with Order #2, I need to:
Run sproc GetOrderInfo (pass parameter OrderId = 1)
Look at field AssociatedOrderId (in this case it equals a string value of "2", but could be null or even a blank string [I know I know, but I don't own the database design])
Run sproc GetOrderInfo (pass parameter OrderId = 2 [OrderId is an int])
Display report
Is this possible in Crystal reports? I cannot see a way to set the parameter of the sproc based on other sproc's returned values.
Database is SqlServer, but I doubt that matters.
You can create a subreport, base it on the same stored procedure and link the parameters values of the subreport to a field in the main report

Passing data from main dataset to table dataset

I'm creating simple report in Jaspersoft Studio 5.6.1 with one table.
Sending data to this report from Java via JRBeanCollectionDataSource.
In report I already can get this data vie fields: report-> DAtaset and Query... -> JavaBean Tab ->
in Class Name write Java class, that comes in list in JRBeanCollectionDataSource -> add selected fields
So now I can display incoming data.
BUT if I want to do it in Table - I need to create Dataset (why?) and choose 'Use same connection used to fill the master report'. Adding same fields to new dataset doesn't help, neither choosing 'Connect to domain' for dataset. No errors displayed.
I need to create Dataset (why?)
In Jasper Reports tables are loosely coupled to the main report, i.e a table requires its own dataset to deal with.
Now say, you have JRBeanCollectionDataSource ready for the report and you wish to use it to fill table with it. Table as I said requires its own datasert, does also require its own datasource.
Now you can either specify a datasource or use same connection to fill the table as that of main report.
For more on jasper report tables visit this link and on java part visit here.
i had a similar problem. I find that you just need is set in the table of your report the REPORT_CONNECTION parameter like say
jaspercomunity
in this.
and then left the value in blank. Later in your java code use a maper object for set the SQL connection to your Data Base, something like this:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=admin");
HashMap<String, Object> hm = new HashMap<String, Object>();
hm.put("REPORT_CONNECTION", conn);
jasperPrint = JasperFillManager.fillReport(reportPath, hm, beanCollectionDataSource);

Create Formula Field that Lists All Tables In Crystal Report

I am looking for a way to create a formula field that will list out the table names of all tables that are being utilized as data sources in a Crystal Report.
I have not found any function that provides that capability in the application yet.
This would be used to put the list of tables as a supplemental for those users that do not have access to the report file but need to know what tables are used in the report.
It seemed better to do this as dynamically as possible - instead of having to provide a static list of current tables linked into the report.
Thanks.
Unfortunately, this type of functionality isn't present in Crystal Reports.
You might be able to use a UFL to solve the problem. General idea:
pass path of current report to UFL (the Filename function will give you this)
open the referenced report using the Crystal Reports SDK and examine the tables in DataDefintion class; the DatabaseFieldDefinition.UseCount will help determine if a field (and hence table) is referenced in the report
return the table names as a string array (note: CR only supports 1-dimensional arrays w/ a maximum of 1000 elements)
create a formula field to call the UFL's function; Join() the string array (formula fields can't return an array):
Join(GetRptTables(Filename), ",")
distribute the UFL with the .RPT
Another option, if you have BusinessObjects Enterprise and a spare $40K, is Metadata Manager; this will give you a holistic view of your organization's reporting deployment.