passing parameter to report.rdlc 2005

Posted on 2007-08-07
Last Modified: 2013-11-26
i want to pass textbox value to report.rdlc parameter
Question by:matalahmari
    LVL 3

    Expert Comment


    There is a detailed explanation of how to pass parameters from parent to child, or between siblings, including a download to the complete code they use, on that page.  I think it should take care of what you need.

    Author Comment

    i designed report (report.rdlc) with parameter (PARAM1)
    then from the form there is text box (txt.text="my name")
    I want pass txt.text = "my name" to PARAM1
    LVL 3

    Accepted Solution

    Hi matalahmari,

    I would suggest, using a storedprocedure for doing this.

    We will do this in 3 Phases, as follows

    PHASE 1 # In SQL Database , create a new stored procedure with your query

    ALTER PROCEDURE [dbo].[spREP_FindByName]
          @Name nvarchar(50)
    SELECT * FROM tblCustomer WHERE (Name=@Name)

    PHASE 2 #  In the Visual Studio , for the report project :

    1. Open the report project and edit the report.rdl
    2. Goto Data tab and select to edit the dataset : Here change 'Query String' to the name of the new storedprocedure(spREP_FindByName) and set the 'command type' to 'StoredProcedure'.Click OK to update the dataset
    3. Now you can execute and test the query for confirmation, Also you can find that a new report parameter is automatically added to the report (in the Layour Tab). (In the reportparameters settings , you can set it to accept null values if you wish)
    4. After this save the report and check the preview, (here you can see that its asking for the parameter). Enter the parameter manually and test to confirm everything is working fine.

    PHASE 3 # Finally in VB2005 (I hope you are using VB)

    1.Copy the newly saved 'report.rdl' to your VB project and rename it to 'report.rdlc'
    2.Add the newly created 'report.rdlc' by using 'Add > Existing Item' from solution explorer
    3.Now create a new form by name "frmReport" and add the reportviewer control to it from Toolbox
    4.Goto 'DataSources' and update your project dataset with using 'Configure Dataset with Wizard' option, Once presented with the list of items, select to add the newly created storedprocedure to your project dataset. In our case select the checkbox for "spREP_FindByName"
    5.Now come back to "frmReport" and from the Datasources drag and drop the "spREP_FindByName" on the form (This creates a datagrid view control, you can delete it if necessary).This create a new binding source and tableadapter for the sp, in our case we get "spREP_FindByNameBindingSource" and "spREP_FindByNameTableAdapter" respectively.
    6.On the reportviewer control open the smart tag pannel (by clicking the triangle that appears on top right corner of report viewer, when you click on the report viewer control),In this you can see the following:

          a.Choose Report : (Select newly added rdlc file from pulldown , in our case 'report.rdlc')
          b.Choose DataSource : Click on this and it opens up a 'choose datasource' dialog , Click on datasource instance pulldown and select newly created bindingsource "spREP_FindByNameBindingSource"

    7.On the form create a textbox (by name txtName)  and a button (by name btnRefresh)
    8.On the click event of the button write the code for refreshing report with txtName value as parameter by using the Fill metod of spREP_FindByName , In our case the code should look like,

            Me.SpREP_FindByNameTableAdapter.Fill(Me.ProjectDataSet.spREP_FindByName, txtName.text)

    Done....!  I hope this was helpful in solving your issue, please let me know if you have any questions.

    Note : Please note that, I have tried to explain this step-by-step, so that this can be helpful for others also who are just beginning with RDLC reports in VB.So please cooperate with my long explanation ....



    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now