How to use Report Parameters to limit data

6 posts, 1 answers
  1. Jim
    Jim avatar
    25 posts
    Member since:
    Mar 2016

    Posted 22 Jul Link to this post

    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.

     

  2. Jim
    Jim avatar
    25 posts
    Member since:
    Mar 2016

    Posted 22 Jul in reply to Jim Link to this post

    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.

  3. DevCraft banner
  4. Martin Gartmann
    Martin Gartmann avatar
    51 posts
    Member since:
    Apr 2004

    Posted 25 Jul in reply to Jim Link to this post

    Dear Jim,

    have you already seen this in the documentation?

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

    Kind regards

    Martin

     

  5. Katia
    Admin
    Katia avatar
    299 posts

    Posted 25 Jul Link to this post

    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
  6. Jim
    Jim avatar
    25 posts
    Member since:
    Mar 2016

    Posted 25 Jul in reply to Katia Link to this post

    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.

  7. Answer
    Katia
    Admin
    Katia avatar
    299 posts

    Posted 25 Jul Link to this post

    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
Back to Top
DevCraft banner