Use query SQL in Crystal report - crystal-reports

I have a complicated SQL in Excel to generate a raw data table for report from SQL server OLEDB . I would like to use Crystal Report to generate a neat and formatted report. I can use the Excel raw data table as the Crystal report database data source. But, Excel need to be refreshed every time new report is required. How can I use the Excel SQL command text string to be Crystal Report data source?
My Excel connect string: Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=MicrosoftDynamicsAX;Data Source=SQL2;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=RD04;Use Encryption for Data=False;Tag with column collation when possible=False
I have Crystal report version 8.5 and 11.

Its simple
While creating the connection dont select tables instead use add command and then paste the query in the box and use in reports

Related

Jasper Report Excel-CSV Export: Prevent executing excel formula

I am using Jasper Report API 4.5 (ready to update if required for this solution). With Jasper Report I am exporting report to HTML, Excel, CSV and PDF. A situation I came across is that if data is having valid excel formula then on exporting data to Excel and CSV and viewing file to MS Excel, it executes excel formula. This causes a security issue as some data is having excel formula to perform some action on local computer then it may harm system.
We can not validate data at the time of insertion, doing so may fix the problem. But currently there is no data validation as such to prevent inserting excel formula. Preferred solution to me is to manage from Jasper Report.
My question is, is there any mechanism or export parameter which can prevent excel formula to be executed? Or is there any way to print data as is and ignore excel formula?
For Excel export:
We can use Apache POI or SmartXLS API to set cell type to Text externally in order to get same result from database.
For Apache POI, we can set cell format type as "#", here is the link from Apache POI javadoc.
For SmartXLS, we can set workbook range style to set format type as Text, code snippet for it would be like below:
RangeStyle rangeStyle = workBook.getRangeStyle(1, 0, 50, 0);
rangeStyle.setCustomFormat("#");
For CSV Export:
Upgraded JasperReport 6.3. There is a feature to add enclosure to csv field. By default excel have single quote (') as field enclosure, so that may execute the field as formula. To avoid that we can set enclosure field to (`).
SimpleCsvExporterConfiguration reportExportConf = new SimpleCsvExporterConfiguration();
reportExportConf.setFieldEnclosure("`");
reportExportConf.setForceFieldEnclosure(true);

How to find what tables are used in SAP Crystal Report 2013?

I am trying to debug missing data in an existing report.
I see the database it is connected to, but I do not find any table or stored procedure or view in that database with the same name that I see in the record selection part of the Crystal Report.
Is there a way to find which table/view/stored procedure is used as input for the Crystal Report?
Thank you
Never mind. I found it. Rt click on Database Fields and select Set Datasource location...
You need to set up first what type of connection you need.
This will help you using ODBC connection.
Ideally you can set this when first time confiugre the data, but suppose if you update the table or procedure and that will not impacted in your crystal report.
To update the updated db element / object in crystal report, simply "Update datasource" option click which pull the changes and update in crystal report.
May be helpfull in future.

Crystal Reports Paramteres

My report is working in Crystal Reports designer, but when I am adding it into the Sage Sales logix it doesnt sends the parameter values to database and errors out.
I am using a command like this in the report
exec('select * from testingmyreportfunction({?Param1},{?Param2})')
Assuming that you created the parameters in command window use this query:
// Oracle
SELECT testingmyreportfunction({?Param1}, {?Param2})
FROM dual
// SQL Server
SELECT testingmyreportfunction({?Param1}, {?Param2})

Replacing Crystal Report data source with store procedure

I used to create crystal reports by going into database expert, selecting tables and specifying the link manually. As I get a bit more comfortable with CR, there is a need for me to put the underlying SQL query into a store procedure to provide data to the report. But doing so will require me to rewrite the whole report which is time consuming.
So, my question is if there are any guru in the community that could and/or have tried to replace the underlying SQL (created by manually add table and links) with a store procedure or cmd without having to rewrite the whole report? I would love to get some hint of how to do that as I have a couple dozen of reports that need "adjustments" and time does not permit me to rewrite them all.
My Crystal Report versions are CR 2008 and CR 2012.
Thank you in advance.
In case you can use an existing software : this feature is available in a free Crystal reports viewer. Here is the documentation, which explains the use :
http://www.r-tag.com/Documents/RTag%20DataSource.pdf
... and here is where you can get your free license:
http://www.r-tag.com/Pages/FreeCrystalReportsViewer.aspx
Crystal does an absolutely horrible job of migrating from many tables to a single DB object, be it a Command or stored procedure.
You might be able to Database | Set datasource location... to map your SP to one of the many tables in the report (choose the one that has the most fields in use); I've never been able to get this feature to work trying to map a Command to a table.
'Best practice' for a really-poor 'feature' set:
create a formula field for each field that will be on the canvas, but isn't grouped (these fields won't be removed when you change datasources)
add the Command to the report; link tables if desired
manually switch grouping, record-selection formula, sorting, etc.

Crystal Reports XI with Oracle Function wm_concat()

Within Crystal Reports XI I'm trying to have a SQL Expression Field with Oracle 10g function wm_concat(column_name). It appears that Crystal Reports XI is not handling this function properly. If I execute the function wm_concat() within the database, it works fine, however, when trying to use it in Crystal Reports it displays a blank page. Whats interesting is that this field is within a sub-report, yet the whole report displays as a blank page.
Crystal Reports can tell at design-time that this function is valid (It doesn't let you save the SQL Expression if its not valid). So its a runtime error. I have also tested using various Oracle functions such as TO_CHAR() and REPLACE() and these all work fine with Crystal Report SQL Expressions. Any ideas?
WM_CONCAT isn't a built-in function, and isn't necessarily installed with a database.
You could try WMSYS.WM_CONCAT, as the function is actually owned by the WMSYS schema.
You may need to add a specific grant. By default, if it is there, it has EXECUTE granted to PUBLIC but your DBA may have revoked that and replaced it with specific grants.
I couldn't get WM_CONCAT to work; Since the queries execute flawless in Oracle, but not in Crystal Reports I would assume it is something within Crystal Reports. I ended up having to make a PL/SQL Stored Procedure and call it from the Crystal Report. I called the Stored Procedure from a SQL Expression Field within Crystal Reports.