am using CR 8.5 to generate report.I am passing a parameter field from VB to crystal report.
I have added the SQL query for the report in which the “WHERE” condition is got from the parameter field.
say
select * from tableA where column1='{?prameter1}’
The report is empty when i preview.. Please advise what am i missing
In the older versions of Crystal, it wasn’t possible to amend queries to include parameter values – you could only add constant values. Consequently, your amended query is selecting records from tableA where column1 is equal to the string “{?prameter1}”, not the value of parameter {?prameter1}.
In order to select by the parameter value, reset the query to its default value – probably:
and add a condition to the Crystal record selection dialog:
(Note – no quotes in the latter condition.)
EDIT:
As noted above, you need to remove the parameter from the query, because it is passed to SQL exactly the way you see it when using Show Query in Crystal. If you amend the query to
select * from tableA where column1={?prameter1}, Crystal will attempt to run that exact string as a SQL statement, and will therefore return an error – it will not attempt to substitute the value of the parameter into the SQL statement.However, if you add a Crystal record selection condition using the parameter into the report, Crystal will attempt to add the selection condition to SQL when running the report – if you use Show Query after adding the Crystal record selection formula, it should first prompt you for a value for your parameter, and then show you a query that includes your selection condition (with the entered value of the parameter, not the parameter name).
There are a couple of restrictions on this automatic addition of Crystal record selection conditions to SQL:
andconditions on database and parameter field values are normally OK, but a mixture ofandandorconditions, or conditions on Crystal formula values, will probably result in Crystal not amending the query conditions.