JRC bug: apostrophe in string parameter passed to Crystal Report with Command datasource to SQL Server

Post Author: nl11087
CA Forum: JAVA
A single quote/apostrophe in string parameter passed to a Crystal Report with Command datasource connecting to a SQL Server database, using sqljdbc driver does not escape the special character correctly. When doing a preview in the Crystal Reports IDE it allows you to escape the input parameter as expected and work correctly, but through the JRC component it fails. For string parameters without special sql server characters I experience no problems at all. When replacing the Command with a direct table there is also no problem.
Reproduction:
1. create a database db1, create a table table1 with a String type column col1.
2. Create new report Report1.rpt, create a connection to above, Add Command using 'SELECT col1, col2, col3 FROM table1 WHERE col1 = '{?Par1}' . Add a parameter field Par1 : String
3. In your java stand alone application using JRC add the parameter Par1 with a value "Jon Doe's Value" containing a single apostrophe. Export to PDF. (I also tried MSWord and this failed too, similar behavior). Additionally, in another test try to replaceAll("'","''") to escape it, preventing the code to break, but now it does not retrieve the expected row anymore and you end up with an empty report.
Exception StackTrace:
com.crystaldecisions.reports.exportinterface.exceptions.ExportException: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)
Caused by: com.crystaldecisions.reports.formatter.formatter.c: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.if(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.e.l.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.e.p.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.e.p.a(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
... 17 more
Caused by: com.crystaldecisions.reports.dataengine.be: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.nr(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.bn(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.bp(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
at com.crystaldecisions.reports.dataengine.s.a(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.aa(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
... 23 more
Caused by: com.crystaldecisions.reports.reportdefinition.datainterface.n: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.reportdefinition.datainterface.p.a(Unknown Source)
... 35 more
Caused by: com.crystaldecisions.reports.queryengine.driverImpl.m: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.queryengine.driverImpl.o.eC(Unknown Source)
at com.crystaldecisions.reports.queryengine.driverImpl.o.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.ap.ea(Unknown Source)
at com.crystaldecisions.reports.queryengine.ap.h(Unknown Source)
at com.crystaldecisions.reports.queryengine.ap.dV(Unknown Source)
at com.crystaldecisions.reports.queryengine.ax.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.bc.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
at com.crystaldecisions.reports.queryengine.ae.cy(Unknown Source)
at com.crystaldecisions.reports.queryengine.ae.cz(Unknown Source)
at com.crystaldecisions.reports.queryengine.b1.bc(Unknown Source)
... 36 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 's'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StatementExecutionRequest.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(Unknown Source)
... 48 more
- JRCAgent3 detected an exception: An error occured while exporting the report
at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)

Post Author: nl11087
CA Forum: JAVA
A single quote/apostrophe in string parameter passed to a Crystal Report with Command datasource connecting to a SQL Server database, using sqljdbc driver does not escape the special character correctly. When doing a preview in the Crystal Reports IDE it allows you to escape the input parameter as expected and work correctly, but through the JRC component it fails. For string parameters without special sql server characters I experience no problems at all. When replacing the Command with a direct table there is also no problem.
Reproduction:
1. create a database db1, create a table table1 with a String type column col1.
2. Create new report Report1.rpt, create a connection to above, Add Command using 'SELECT col1, col2, col3 FROM table1 WHERE col1 = '{?Par1}' . Add a parameter field Par1 : String
3. In your java stand alone application using JRC add the parameter Par1 with a value "Jon Doe's Value" containing a single apostrophe. Export to PDF. (I also tried MSWord and this failed too, similar behavior). Additionally, in another test try to replaceAll("'","''") to escape it, preventing the code to break, but now it does not retrieve the expected row anymore and you end up with an empty report.
Exception StackTrace:
com.crystaldecisions.reports.exportinterface.exceptions.ExportException: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)
Caused by: com.crystaldecisions.reports.formatter.formatter.c: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.if(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.e.l.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.e.p.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.e.p.a(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
... 17 more
Caused by: com.crystaldecisions.reports.dataengine.be: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.nr(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.bn(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.bp(Unknown Source)
at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
at com.crystaldecisions.reports.dataengine.s.a(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.aa(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
... 23 more
Caused by: com.crystaldecisions.reports.reportdefinition.datainterface.n: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.reportdefinition.datainterface.p.a(Unknown Source)
... 35 more
Caused by: com.crystaldecisions.reports.queryengine.driverImpl.m: JDBC Error: Incorrect syntax near 's'.
at com.crystaldecisions.reports.queryengine.driverImpl.o.eC(Unknown Source)
at com.crystaldecisions.reports.queryengine.driverImpl.o.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.ap.ea(Unknown Source)
at com.crystaldecisions.reports.queryengine.ap.h(Unknown Source)
at com.crystaldecisions.reports.queryengine.ap.dV(Unknown Source)
at com.crystaldecisions.reports.queryengine.ax.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.bc.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
at com.crystaldecisions.reports.queryengine.ae.cy(Unknown Source)
at com.crystaldecisions.reports.queryengine.ae.cz(Unknown Source)
at com.crystaldecisions.reports.queryengine.b1.bc(Unknown Source)
... 36 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 's'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StatementExecutionRequest.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(Unknown Source)
... 48 more
- JRCAgent3 detected an exception: An error occured while exporting the report
at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)

Similar Messages

  • Setting VarChar Variable with String Parameter in Crystal Report Add Command

    Setting a VarChar Variable with a String Parameter in a Crystal Report 2008 SP6.3 Add Command is causing an error with a SQL State of 42000.  The Error Code depends on which value I select for the parameter.  I created the @DateOpt string parameter in the Modify Command window, not in the report. If I comment out line 14 of the SQL the error does not occur.
    I have attached the SQL Code and screen shots of the errors.   Please tell me what I am doing wrong.

    Since your parameter is of type STRING, you need to enclose references to it within the Command inside single quotes.
    For example, instead of
    SET @BeginDate ={?BeginDate}
    use
    SET @BeginDate ='{?BeginDate}'
    hth,
    - ido

  • Bug while using string parameter values in postgresql query

    Hi,
    I have the following query for the postgresql database:
    Code:
    <queryString><![CDATA[SELECT
    evt_src_mgr_rpt_v."evt_src_mgr_name" AS esm_name,
    evt_src_collector_rpt_v."evt_src_collector_name" AS collector_name,
    evt_src_grp_rpt_v."evt_src_grp_name" AS grp_name,
    evt_src_grp_rpt_v."state_ind" AS state_ind,
    evt_src_rpt_v."evt_src_name" AS src_name,
    evt_src_rpt_v."date_modified" AS date_modified,
    evt_src_rpt_v."date_created" AS date_created,
    CASE WHEN $P{mysortfield} = 'evt_src_mgr_name' THEN evt_src_mgr_name
    WHEN $P{mysortfield} = 'evt_src_collector_name' THEN evt_src_collector_name
    WHEN $P{mysortfield} = 'evt_src_grp_name' THEN evt_src_grp_name
    ELSE evt_src_name END as sort
    FROM
    "evt_src_mgr_rpt_v" evt_src_mgr_rpt_v
    LEFT JOIN
    "evt_src_collector_rpt_v" evt_src_collector_rpt_v
    ON EVT_SRC_MGR_RPT_V."evt_src_mgr_id" = evt_src_collector_rpt_v."evt_src_mgr_id"
    LEFT JOIN
    "evt_src_grp_rpt_v" evt_src_grp_rpt_v
    ON evt_src_collector_rpt_v."evt_src_collector_id" = evt_src_grp_rpt_v."evt_src_collector_id"
    LEFT JOIN
    "evt_src_rpt_v" evt_src_rpt_v
    ON evt_src_grp_rpt_v."evt_src_grp_id" = evt_src_rpt_v."evt_src_grp_id"
    LEFT JOIN
    "evt_src_offset_rpt_v" evt_src_offset_rpt_v
    ON evt_src_rpt_v."evt_src_id" = evt_src_offset_rpt_v."evt_src_id"
    WHERE
    $P!{mysortfield} LIKE '$P!{searchvalue}' || '%']]></queryString>
    That is I try to select only the records where the field which is
    selected by user as report parameter ($P{mysortfield}) contains data
    starting with the text entered by user as a report parameter
    ($P{searchvalue}).
    When I try to run the report in iReport with active connection to the
    database the report is generated as expected.
    But when I try to run the report from Sentinel Log Manager I get the
    following error: "java.lang.String cannot be cast to
    net.sf.jasperreports.engine.JRValueParameter".
    After several detailed debug sessions I finally came into a conclusion
    that this error is related to the use of parameter values (
    $P!{mysortfield} and $P!{searchvalue} ).
    I even tried using the following WHERE clause (which emulates the
    queries as used in standart reports (especially at VendorProduct related
    SQL queries ) with no success:
    Code:
    WHERE
    ($P{mysortfield} = 'evt_src_mgr_name' AND evt_src_mgr_name LIKE ($P{searchvalue} || '%')) OR
    ($P{mysortfield} = 'evt_src_collector_name' AND evt_src_collector_name LIKE ($P{searchvalue} || '%')) OR
    ($P{mysortfield} = 'evt_src_grp_name' AND evt_src_grp_name LIKE ($P{searchvalue} || '%')) OR
    ($P{mysortfield} = 'evt_src_name' AND evt_src_name LIKE ($P{searchvalue} || '%'))
    Any suggestions?
    hkalyoncu
    hkalyoncu's Profile: http://forums.novell.com/member.php?userid=63527
    View this thread: http://forums.novell.com/showthread.php?t=450687

    bweiner12345;2167651 Wrote:
    > I'm not 100% sure the $P! (instead of just $P) is needed in that WHERE
    > portion of your SQL statement.
    >
    > What I would suggest doing is building the WHERE portion of your query
    > up again step by step. That is, instead of using any parameters in your
    > WHERE:
    >
    > $P!{mysortfield} LIKE '$P!{searchvalue}' || '%'
    >
    > ... take a step back and literally hard-code some values in there, such
    > as:
    >
    > evt_src_mgr_name LIKE '%' || '%'
    >
    > ... and run it on your box to make sure it works fine.
    >
    > If it works fine, start substituting the parameters one by one:
    >
    > $P{mysortfield} LIKE '%' || '%'
    >
    > .... test on the box.
    >
    > $P{mysortfield} LIKE '$P{searchvalue}' || '%'
    >
    > .... test on the box.
    >
    > It may be a little tedious, but at least you'll find out where the
    > problem is occurring... and may be quicker in the long run.
    >
    > (Note: In my above example steps I didn't use the ! in with the
    > parameters, as I don't think they are needed in the WHERE clause... but
    > I could be wrong... and by following the above step-by-step technique
    > should answer that for sure.)
    Thank you for the suggestions:
    While trying to implement your suggestions I realized that there was a
    error at the parameter name I used inside the where clause (it should be
    $P{searchfield}).
    Here are my results:
    Code:
    vt_src_mgr_name LIKE '%' || '%'
    worked as expected.
    Code:
    $P{searchfield} LIKE '%' || '%'
    produced PDF but wrong output.
    Code:
    $P!{searchfield} LIKE '%' || '%'
    resulted with the error "java.lang.String cannot be cast to
    net.sf.jasperreports.engine.JRValueParameter" and no PDF.
    Then I tried the following where clause which resulted in exactly as
    expected PDF:
    Code:
    WHERE
    ($P{searchfield} = 'evt_src_mgr_name' AND evt_src_mgr_name LIKE ($P{searchvalue} || '%')) OR
    ($P{searchfield} = 'evt_src_collector_name' AND evt_src_collector_name LIKE ($P{searchvalue} || '%')) OR
    ($P{searchfield} = 'evt_src_grp_name' AND evt_src_grp_name LIKE ($P{searchvalue} || '%')) OR
    ($P{searchfield} = 'evt_src_name' AND evt_src_name LIKE ($P{searchvalue} || '%'))
    As a summary:
    * The query which works in iRepord do not work in Sentinel Log
    Manager.
    * I found a workaround for my case.
    * I did not checked, but the reports provided in Sentinel RD which use
    the same technique for VendorProduct parameter (i.e. the reports with
    query string containing
    Code:
    LIKE ($P{VendorProduct} || '%')
    will most probably not work as expected IF Sentinel RD uses the same
    code as Sentinel Log Manager.
    hkalyoncu
    hkalyoncu's Profile: http://forums.novell.com/member.php?userid=63527
    View this thread: http://forums.novell.com/showthread.php?t=450687

  • Does BOXI support crystal reports with parameter references in formulas?

    I am designing a report in Crystal Reports XI Developer that contains parameters, which are passed to a stored procedure and are also used within formulas ( in Crystal Syntax ie. {?FORMAT_ID} ) in the report itself.
    I can run the report successfully in CRXI Developer.  The formulas use the correct values from the parameters entered during execution and everything looks good.
    I then deploy the report to Business Objects Enterprise XI.  I do all of the things necessary to manage the report including setting up the proper database connection information and default parameter values.
    When I run the report using the Crystal Report Viewer, I get the following error message:
    Error in File Forecasting.rpt:
    Error in formula <Report Format>.
    'if (not isNull({?FORMAT_ID} ) ) then
    This field name is not known.
    Details: errorKind
    This happens when I press the "Preview" button in the Manage Object dialog from Crystal or when I run the report using InfoView.
    I have changed the formulas and it doesn't seem to matter what the specific content of the formula is; other than the existence of a parameter reference in the formula.  If I comment out the parameter and replace it with a hard-coded value, it gets through the formula fine.
    Does Business Objects Enterprise XI support crystal reports with parameter references in the formulas?
    Thanks,
    Tim H.

    Hi,
       In Crystal Reports under File -> Report Options >check convert Null Values to default > Verify on first refresh > Verify stored procedures on first refresh.
    This corrected the issue by allowing the query engine time to locate those columns and map them to the query being sent by the report.
    The convert null values was added because those field were being used in the record selection and grouping.
    Regards,
    Vinay

  • How to set defalt parameter(s) for Crystal Report in CRS

    Hi everybody,
        I am new to Crystal Report designing and Crystal Report Server. My problem is; I had created one Crystal Report with sub-reports and some parameters. I had given default value for those parameters. These parameters are there in main report and linked with sub-reports. After that I deployed it in the Crystal Report Server.
        Now i want to schedule the report. while scheduling the report, I want to run the report using default parameter(s). If I Clicked on Schedule button, it is giving "report failed" error. And in parameter list it is showing "No parameters". Why this is happening? Is this default behaviour of Crystal Report Server? Can anybody please suggest me how can I give default values for a report automatically?(using Crystal Report Server)
    Thanks in Advance.
    Jithesh

    Not sure if I understand the question correctly or not.  It sounds like you have a main report, with a sub-report and a value is being passed from the main to the sub-report.
    When you say you created some parameters, are those parameters in the sub-report or main report?
    If it were me I would create a parameter in the main report, and a parameter in the sub report.  Have the two reports link on the two parameters. 
    When you go to schedule the job, set the default value in the cmc under process/parameters. 
    Let me know if this answers your question.  I tend to not fully understand the problem often times.
    Good luck!
    Rody

  • How to get Description of parameter filed in Crystal report 2008

    Hi expert,
    I am creating a crystal report from Query ,which is created in BEX    Query designer 7.
    In query designer i have some selection variable.
    The requirement from clint is that they want to see what value is selected for all  variable.
    when i tried to put all parameter field in crystal report it is showing only Technical name of value selected not  description and also it show only for variable which is single value variable  not for the range value variable and multiple selection variable.
    can any one help me How to get description of value in report and can it is possible to show Range value and multiple value for a particular variable .
    i am using Crystal report 2008 SP3 version.
    Thanks and regards
    devendra

    Moved to BEx forum

  • Crystal Report with text(csv) data file, can we set it as input parameter?

    Hi,
    I am a new user of Crystal Reports 2008.
    I have created a report with charts in it. The input data comes from a csv text file.
    Can I set the name of this text file as an input parameter?
    as I need to generate 44 similar reports with different text filenames(and data)?
    Thank you.
    Regards

    Brian,
    Thanks much.
    I did exactly what you said.
    Just to see any change, I first gave a bad report file name just to see if I am accidentally pointing to a different file,
    but I got an error saying report not found.
    Then I renamed my original datafile name and generated a report and it still generated one without giving an error.
    Then I also gave a junk name to the logoninfo and printed that name, the new name was assigned to logoninfo, but the code did not error out.
    It ended up generating the report.
    Now here is what I think is happening,
    1) The save data in report option seems to be still on even though I have turned it off in 2 locations
    a) file -> Report Options
    b) file -> Options -> Reporting tab.
    2) For some reason the logoninfo is getting ignored as well.
    Since I did not see any answers yesterday I posted a link to this thread on the .Net forum
    Crystal Report with text(csv) data file, can we set it as input param? C#
    and Ludek Uher says that I am connecting to the text file via a DAO database engine and so need to use the same code for changing the text file as for changing an Access database.
    But the link he gave me tells me to try the same thing that we have been trying..
    Here is my plan,
    1) I will first try and find out why my save data with report option is still on ( but it shows off in Crystal ).
    2) why is LogonInfo getting ignored.
    Meanwhile any suggestions from anyone are welcome.

  • One parameter for multiple Crystal reports in Publication

    Does anyone know if it is possible to enter one identical parameter for multiple Crystal reports in publication when scheduling? BOE 3.1 SP3 Windows, Java.
    To elaborate I am creating publication with multiple reports, each report has one parameter and this parameter is identical in every report in publication. So instead of entering this parameter many times I would like to enter once. 
    If yes point me in the right direction to get the how to or post the steps.

    Daniel,
    Thank you so much for your answer. It was very helpful. In the end, it didn't work but it helped me figure out what was happening. I use a different form for the reports and I had it coded in the form which report to use. I created a second form for the second crystal and then I used an if statement to choose the form and it worked like a charm.
    Thanks so much again!

  • Problems with parameter button in Crystal Report Server  2008

    Dear all,
    I have problems with parameter button in Crystal Report Server 2008.
    when I created some parameters and groups in Crystal Report 2008, they showed both parameters in 'Parameter button' and group in 'Group button'  on the left, so I can choose or type without clicking 'Refresh button' But when I added it to Crystal Report Server 2008 and I click parameter button , it doesn't show any parameter. Only click refresh button to choose them. On the other hand, for 'Group Tree' is ok. When go to Default Setting-> Parameter, all parameters are in 'Unused parameter'  First time I think I had problems with my installation, but when I reinstalled it again, it was like before.
    Could any one help me with this?
    I appreciate looking forward to your reply
    Ketya

    Try posting your questionin the correct forum, this is for SAP Business One, not Crystal reports Server

  • Connecting Crystal reports with dashboards and passing parameters

    Hi ,
    Can anyone have any document on Connecting Crystal reports with dashboards and passing parameters.
    I would appreciate for this.
    Thank You.

    Hi Ganesh,
    You can refer the following links for connecting Crystal reports with dashboards:
    Dashboard integration in Crystal Reports using flash variables | Clariba Blog
    https://websmp102.sapag.de/~sapidp/011000358700001426732009E/Xcelsius_EmbeddingInCR2008.pdf
    http://events.asug.com/2012BOUC/0315_Integrating_SAP_Dashboards_into_SAP_Crystal_Reports.pdf
    Regards,
    Renu

  • Problems with Flexible Parameter Passing - Can anyone help with the answer

    Hi,
    having gone to the trouble of creating a generic form handler which utlises the ability of the PL/SQL Gateway to handle flexible parameters, we've come across an almighty problem.
    Whilst the gateway will create two arrays of parameter names and values, it doesn' t seem to handle arrays of values. So, although some of our forms have multi select list form elements, these seem to be incompatible with the Flexible parameter method, as only the first value is returned.
    Does anyone know of a solution to this?
    I really hope so, otherwise the whole methodology is a waste of effort, and I can't imagine why Oracle bothered to include it!
    Here's hoping.
    Thanks
    Dan

    Not sure what flexible parameters are but in the past I've worked on a form that had to pass multiple values (from a multi-select list item) to a report via a single parameter. We did this by creating a pipe delimited ("|") string of all the selected values. Leading and trailing pipes were also added to the concatenated string.
    This was exploded into individual rows by using the statement below:
    WITH t AS (SELECT '|1|2|3|4|' str FROM dual)
    SELECT str, level
    , SUBSTR(str, INSTR(str, '|', 1, level) +1, INSTR(str, '|', 1, level+1)-INSTR(str, '|', 1, level)-1) str2
    FROM t
    CONNECT BY INSTR(str, '|', 2, level) <> 0;
    '|1|2|3|4|' is the value of the passed in parameter.
    So the report query could look something like
    WITH t AS (SELECT SUBSTR(:p_str, INSTR(:p_str, '|', 1, level) +1, INSTR(:p_str, '|', 1, level+1)-INSTR(:p_str, '|', 1, level)-1) itemid
    FROM dual
    CONNECT BY INSTR(:p_str, '|', 2, level) <> 0)
    SELECT a.*
    FROM items a, t
    WHERE a.itemid = TO_NUMBER(t.itemid);
    Hope this helps.

  • Pass querystring parameter value to crystal report

    Post Author: hani1426
    CA Forum: .NET
    Hi all,
    I am new in using crystal reports
    I want to print an invoice with it's items in a crystal report,I have aseparated page which contains a GridView of invoices and it has a hyperlink field column which parse the ID of the invoice to the page of the crystal report
    In my crystal report I am using "Microsoft OLE DB Provider for SQL Server" Connection which connects to my local instance of SQL server express edition and then add a "command" to obtain the invoice details
    BUT: when adding a parameter to my command it gives an error which description is: "Must declare the scalar variable @ID"
    please how can I add this parameter
    thanks for any help
    bye

    I responded to your other thread:
    pass parameters from vb.net to crystal report
    Please do not cross post. See the [Rules of Engagement|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement]
    Closing and locking this thread.
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Passing a table-field value in Crystal to a Store Procedure in SQL Server

    I have been checking all over the interenet via searches and although some seem to come close to this, its still not what I want.
    Essentially I need to pass value from Table-Field record (for each record read/selected) via a paramete to a Stored Procedure(SP) in SQL Server 2205/2008.  I do NOT want to be prompted for a value for this parameter each time the report is run, simple pass the value in which will be used along with other select criteria to bring back one value for the report to use in a calcuation per record.
    The value of the parameter is a date, but I understand it would be better to pass it in as a varchar(8) - 'YYYYMMDD' - and then reconvert it inside the SP, as follows:
    In Crystal Reports 2008 SP3, I have a formula defined as,
    trans_date = ToText ({F1ARS_STMT_WS_TRAN.TRANS_DATEI}, 'YYYYMMDD')
    and essential just want to pass this to the SP below ... i.e. trans_date  ---> @strTransDate
    I then link the key fields [EXCH_RATE_TABLE_NAME] and [TRANS_CCY_CODE] to other tables in the Database Expert, and put [EXCH_RATE_AMT] on the report and use it to calculate what I want.
    This works fine when the prompt comes up and I put in a proper date, but I don't what it to prompt, but simple pass the F1ARS_STMT_WS_TRAN.TRANS_DATEI in via the fornula/parameter and let teh SQL do the rest for each record selected..
    CREATE PROCEDURE [dbo].sp_GET_EXCH_RATE_AMT (@strTransDate varchar(8))     --use format 'YYYYMMDD' to represent the date as a string.
         -- Add the parameters for the stored procedure here
         -- @TransDate datetime = now
    AS
           declare @TransDate datetime
         set @TransDate = CONVERT(DATETIME, @strTransDate, 112)
    BEGIN
         -- SET NOCOUNT ON added to prevent extra result sets from
         -- interfering with SELECT statements.
         SET NOCOUNT ON;
        -- Insert statements for procedure here
    SELECT [EXCH_RATE_TABLE_NAME], [TRANS_CCY_CODE], [EXCH_RATE_AMT]
    FROM [F1CCY_EXCH_RATE]
    WHERE [MAJOR_CCY_CODE] = 'BBD'
    AND   [START_DATEI] =
         SELECT MAX([START_DATEI])
         FROM [F1CCY_EXCH_RATE]
         WHERE [MAJOR_CCY_CODE] = 'BBD'
         AND   [START_DATEI] <= @TransDate
    END
    GO
    GRANT EXECUTE ON sp_GET_EXCH_RATE_AMT TO PUBLIC
    GO
    Thanks for any help.  Can't tell the headache this has caused my both literally and figuratively.

    Hello,
    I moved your post to the Report Design forum. Lots of SQL help in here...
    I believe the problem is due to you using a Parameterized Stored Procedure. The first thing CR has to do is connect to your DB source which requires the date parameter before it can run the query to add the date filter, it's the SP that is prompting for the parameter. Therefore the report has not run so it can't get the field value from the report until you fill in the info for the SP. Catch 22 problem.... Which came first, the Chicken or the Parameter....
    The report will work as you have noted but I don't know of anyway to refresh unless parameter is filled in again....
    Jason has a lot of great solutions when it comes to these dilemmas, Possibly using a Command Object may help but I believe you will still run into the same issue....
    Only way I can think of is to not use a parameter in the SP and let CR do the filtering client side. Of course this means all data is coming back to the client PC as you are likely trying to find a work around for.
    Thank you
    Don

  • Passing parameters from vb form to a crystal report with stored procedure

    Can someone give me an idea how to use data inputted on vb form to be use as basis of crystal report generation which loads data from a stored procedure. Stored procedure has parameters that was also set in the crystal report. viewing on crystal report is ok but i am having difficulty running the report from vb.

    Hi John,
                  If Not CRRpt.ParameterFields("AgeType") Is Nothing Then
                        CRRpt.ParameterFields("AgeType").CurrentValues.Clear()
                        Dim ParamValue As new CrystalDecisions.Shared.ParameterDiscreteValue
                        ParamValue.Value = AgeType.ToString 
                        CRRpt.ParameterFields("AgeType").CurrentValues.Add(ParamValue)
                    End If
    Note that the ParamValue.Value should be assigned with exact same data type as you declared it in CR.
    If it is string, Convert your Variable to string first.
    If it is date, make sure you are passing a date variable.
    and so on...
    Regards
    Edy

  • Limitation on data passed to Crystal Report

    Hello, I have a very basic question that I cannot find the answer to in the manual or online.
    We are pulling data from a SQL 2005 database.  Specifically, we are querying information that contains very complicated legal instructions - the equivalent of two dozen pages of text.
    We are finding that the data is being truncated once it reaches the report to about 7 pages....
    Is there a limit on the amount of data Crystal Report XI can bring across from a single record. Or is this a limitation of the report itself? I am working with the developers who are struggling to make this work correctly and I am trying to get to the bottom off this.
    Thanks for your time!
    Dirk

    I believe there is a limit to the length of string Crystal can work with, although I can't remember what it is off the top of my head, but probably 65534 characters - once upon a time it was 256 characters!
    You could try working around this limitation by creating a few formulas, grabbing, say, the nth 1000 characters and storing it into a variable.
    eg:
    stringvar part1:=left(YourField, 1000);
    stringvar part2:=mid(YourField, 1001, 2000);
    stringvar part3:=mid(YourField, 2001, 3000);
    etc...
    Of course, you could wrap that up in a loop to automate it if you'd prefer.
    Then, create a formula for each of the above "part(x)" variable to display the contents:
    //Formula @show_part1
    stringvar part1
    //Formula @show_part2
    stringvar part2
    etc...
    Finally, drop each of these "show" formulas into a single textbox and hopefully, you should get what you need.
    If not, chop it up in the SQL command/view/whatnot and return it as seperate columns and concat them in a similar textbox fashion?
    Let us know how you get on...
    Ta,
    J

Maybe you are looking for