Passing paramaeters to a Stored Procedure

6 posts, 0 answers
  1. Dan
    Dan avatar
    28 posts
    Member since:
    Nov 2005

    Posted 21 Sep 2007 Link to this post

    Hi,

    Is there an easy / codeless way to pass Report Parameters to a stored Procedure or DataSet, rather than filtering the data?

    Using filters seems very inefficent, as all data needs to be read from the database, passed to the report, and then filtered. This is fine for small tables but not on those with tens of thousands of records plus.

    I cannot see any documentation on filters / parameters on the site, I assume these are forthcoming?

    Thanks,
    Dan.

  2. Dan
    Dan avatar
    28 posts
    Member since:
    Nov 2005

    Posted 21 Sep 2007 Link to this post

    Any update would be appreciated as this seems to be the main obstacle in incorporating this reporting system.
  3. DevCraft banner
  4. Hrisi
    Admin
    Hrisi avatar
    221 posts

    Posted 24 Sep 2007 Link to this post

    Hi Dan,

    You are right, in the current implementation Report Parameters are applied after all data are fed from the DataSource. We are considering these features for the next release. 

    In mean time it is possible to pass query parameters as explained in this video. As you can see it is not so difficult to add such functionality.

     
    Kind regards,
    Hrisi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Dan
    Dan avatar
    28 posts
    Member since:
    Nov 2005

    Posted 25 Sep 2007 Link to this post

    PLESAE IGNORE THIS POST: I got the required functionality by using 
    Report.Filters.RemoveAt();

    _________________________________________

    Thanks, the video helped greatly.

    I have now managed to reduce the amount of data coming into the report, and would further like to reduce the fields displayed by using the Report Filters.

    The one issue i'm having is that I would to provide users with optional filters, e.g. they can filter if they want, but they don't have to. I have a boolean column that a user can filter using a dropdown list with the following options:

    No Filter
    True
    False

    The true/false options work fine, but I can't seem to get a way of making the filter irrelevant by selecting the 'No Filter' option. Is there a way to turn off the filter if a certain value is selected?

    Thanks,
    Dan.
  6. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 25 Sep 2007 Link to this post

    I did it this way and it seems to work pretty well.  I think this is what you are asking for.


    .aspx.vb just has this in it
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init, ReportViewer1.DataBinding 
            Dim _qsval As Int32 
            _qsval = Request.QueryString("qsval") 
            Dim myreport As New Reports_ReportByID(_qsval) 
            ReportViewer1.Report = myreport 
        End Sub 


    the report class just does this then.
      Public Sub New(ByVal _myval As Int32) 
            InitializeComponent() 
            Dim ds As DataSet 
            ds = GetMyData(_myval) 
            Me.DataSource = ds 
     
            txtPageCount.Value = "='Page ' + PageNumber + ' of ' + PageCount" '; '"Page " + PageNumber 
        End Sub 
     
        Public Function GetMyData(ByVal _myval As Int32) As DataSet 
            Dim mysql As String 
            mysql = "exec sp_MySP " & _myval 
            Return objdo.daGetDataSet(mysql) 
        End Function 


  7. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 25 Sep 2007 Link to this post

    Hi Guys,

    It's great that you've managed to solve this very interesting task.

    We would like to share with you two more approaches that we consider very interesting. Both of them rely on the new functionality that Telerik Reporting Q2 2007 introduces - filters, report parameters and user defined functions.

    Lets assume that we've defined one report parameter named UserSelection (referenced later as Parameters.UserSelection) that holds the chosen filter (No Filter, True, False) and the field that we'll filter by is named TrueFalse (referenced later as Fields.TrueFalse).

    The 1st approach uses only one filter defined for the report:

    new Filter("=IIF(Parameters.UserSelection = "No Filter", True, Parameters.UserSelection)", FilterOperator.Equal, "=IIF(Parameters.UserSelection = "No Filter", True, Fields.TrueFalse)");


    The 2nd approach instruments one user defined function:

    public static bool IsRowSelected(string userSelection, bool field)
    {
        switch (userSelection)
        {
            case "No Filter":               
                return true;

            case "True":
                return (field == true);

            case "False":
                return (field == false);
        }

        return false;
    }


    and then uses it in the next report filter:

    new Filter("=IsRowSelected(Parameters.UserSelection, Fields.TrueFalse)", FilterOperator.Equal, "=True");

    We personally prefer the 2nd option as using custom functions is much more descriptive, easy to read and maintain, and the report filter is simpler.

    The above examples illustrate the flexibility of the new reporting engine and the endless capabilities that it offers.

    I hope this helps.
     

    Sincerely yours,
    Svetoslav
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
DevCraft banner