Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8572
  • Last Modified:

passing parameter to report.rdlc vb.et 2005

i want to pass textbox value to report.rdlc parameter
0
matalahmari
Asked:
matalahmari
1 Solution
 
keihatsuCommented:
http://www.codeproject.com/dotnet/passingvaluesbetweenforms.asp

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.
0
 
matalahmariAuthor Commented:
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
0
 
S_ManiCommented:
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)
)
AS
SET NOCOUNT ON;
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)
        Me.ReportViewer1.RefreshReport()


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 ....

thanks
S.Mani

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now