Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to connect rdlc Report Parameters to Stored Proc Parameters

Status
Not open for further replies.

j0em0mma

Programmer
Jul 31, 2003
131
US
I have a stored procedure accepting from and to date as parameters to an Group By Select. I have added this as a datasource and even have the report designed and showing up fine except...

I cannot find an example of passing parameters from a control (say, DateTimePicker) on the WindowsForm that the ReportViewer appears on to the report as a parameter and then on to the Stored Procedure. How is this done?
 
So this is how it's done:

1) in Visual Studio 2005, choose Menu->Data->Add New Data Source. Choose Database, then enter the appropriate connection string. Then enter an appropriate name for the data source. Once the database objects are listed, choose the desired stored procedure, plus the desired fields produced by the stored procedure. Click Finish. You will have an 'XSD' file in your solution with the name you gave the dataset.

2) Right Click on solution, Add Report. Give appropriate name and save. From Tools, add whatever appropriate Report controls you want, and fill them by dragging over the appropriate fields from your new dataset in the Data Sources Panel, then save.

3) On your Windows Form, add a ReportViewer. It will ask you what report you wish to use (Choose the report you just made in step 2). Dock if you like.

4) If your stored procedure has parameters, and you try to build now, it will fail. You must view code for this Windows Form, and find this line (in the load section of the form):
Code:
'TODO: This line of code loads data into the 'ds_OrdersDistributed.sp_OrdersDistributed' table. You can move, or remove it, as needed.
Below this line will be
Code:
Me.[i]Your_Stored_Procedure_Name[/i].Fill(Me.[i]Your_DataSource_Name[/i].[i]Your_Stored_Procedure_Name[/i])
with a squiggly line. To finish, add each parameter your stored procedure needs as an overload to this method call. Once you have entered a value for each parameter, the project should build, and voila, you have your report.

Code:
Me.[i]Your_Stored_Procedure_Name[/i].Fill(Me.[i]Your_DataSource_Name[/i].[i]Your_Stored_Procedure_Name[/i], [i]parameter1[/i], [i]parameter2[/i], etc...)
Hope this helps!
 
So, this doesn't really address using Report Parameters added while creating the report. If anyone is interested, I will figure this out and post it, though I don't need it now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top