This is a migrated thread and some comments may be shown as answers.

How to use Report Parameters to limit data

5 Answers 749 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 22 Jul 2016, 01:55 PM

I am very green with reporting in general.

I am using VS2013 to design a simple report.

- I created a report and a data source.

- I added a report parameter and a data source to show a list of available values.

 

My question:

1) How do I take the report parameter and tie it to my data source?

 

For example the data source is simple "SELECT * FROM BOOKS"

I would like to set up as "SELECT * FROM BOOKS WHERE BOOK_TYPE  = [MY PARAMETER]"

I manually added the following to my SelectCommand for the data source

SELECT * FROM BOOKS WHERE BOOK_TYPE  == Parameters.ReportCodeParam.Value

However that didn't work.

On the data source I also see a Parameters property.  When I go to that property I don't see the parameter that I created on the report.

 

Please advise.

 

5 Answers, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 22 Jul 2016, 02:21 PM

I was able to create a parameter in the datasource and link it's value to the report parameter that I created.

However I'm still stuck on tying that parameter back to the sql statement.

0
Martin Gartmann
Top achievements
Rank 2
answered on 25 Jul 2016, 06:48 AM

Dear Jim,

have you already seen this in the documentation?

http://docs.telerik.com/reporting/designing-reports-parameters-programmatic-control

Kind regards

Martin

 

0
Katia
Telerik team
answered on 25 Jul 2016, 01:12 PM
Hi Jim,

If the report already has report parameters configured you can map them to data source parameters - check Using Parameters with the SqlDataSource component and SqlDatasource Wizard(step 4) for more detailed information.

After that, you can use this parameter in the SQL query as following:
SELECT * FROM Books WHERE BookType = @BookType


I hope this information will help.

Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jim
Top achievements
Rank 1
answered on 25 Jul 2016, 01:36 PM

This is what I have tried:

- I added a parameter to the sqlDataSource

- I configured the sqlDataSource to use that parameter.

i.e. Changed the select command to:

SELECT  field1, field2, field3 FROM MyTable
WHERE MyCode = @ReportType

- Rebuilt the solution.

When I click the "Preview" tab I enter my parameter.

I then get an error: ORA-00936 missing expression on the report.

 

Please advise.

0
Accepted
Katia
Telerik team
answered on 25 Jul 2016, 03:17 PM
Hi Jim,

Check if SQL query follows the syntax for the selected database engine.
If you are working with SQL Server the parameter name begins with the '@' character and this name should correspond to the name of the report parameter.
For Oracle databases, the parameters are prefixed with the ':' character and for ODBC or OLE DB databases, parameters are not named and are specified with the placeholder character '?'.

For more information, check Using Parameters with the SqlDataSource component help article.



Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Martin Gartmann
Top achievements
Rank 2
Katia
Telerik team
Share this question
or