I am trying to create a report with the Report Viewer. There is no problem
when I use data from a table. But when I take the data from a stored
procedure I only get the headlines in the table. I think my problem is that
I don't know how to pass the parameters to the report.
Can anybody help?
Thanks in advance.
Peer Groendahl
Charles Wang [MSFT] - 14 May 2008 08:34 GMT
Hi Peer,
I understand that your report was not fully displayed but the headlines in
your report viewer control.
If I have misunderstood, please let me know.
I suppose that you used local processing report (.rdlc) in your project
since a server report can include a parameter input area at the top of the
report so that you need not do anything for parameterization.
For parameterization in local processing report, I recommend that you refer
to the following steps of my test:
1. Assume that you have the following stored procedure in AdventureworksDW:
CREATE PROCEDURE usp_getInternetSales
(
@productKey int
)
AS
SELECT SalesOrderNumber, SalesOrderLineNumber, RevisionNumber,
OrderQuantity,UnitPrice,ExtendedAmount,DiscountAmount
FROM dbo.FactInternetSales WHERE ProductKey=@productKey
2. In your project, create a new report and add the datasource and dataset
which contains your stored procedure.
3. Drag the columns in the dataset to your report and select Report->
Report Parameters... from the top menu, click Add to add a parameter with
the name "productKey", data type "Integer" and Prompt "product key". Then
click OK.
4. Click your reportviewer control and choose your report for the control;
5. You can write the following code in your project to set parameter:
===================================
this.usp_getInternetSalesTableAdapter.Fill(this.AdventureWorksDWDataSet.usp_
getInternetSales, Int32.Parse(this.txtProductKey.Text));
ReportParameter p = new
ReportParameter("productKey",this.txtProductKey.Text);
this.reportViewer1.LocalReport.SetParameters(new
ReportParameter[] { p });
this.reportViewer1.RefreshReport();
=======================================
You may also refer to the following article:
Defining Report Parameters in a ReportViewer Report
http://msdn.microsoft.com/en-us/library/ms251685(VS.80).aspx
Hope this helps. If you have any other questions or concerns, please feel
free to let me know. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================
Charles Wang [MSFT] - 14 May 2008 08:34 GMT
Hi Peer,
I understand that your report was not fully displayed but the headlines in
your report viewer control.
If I have misunderstood, please let me know.
I suppose that you used local processing report (.rdlc) in your project
since a server report can include a parameter input area at the top of the
report so that you need not do anything for parameterization.
For parameterization in local processing report, I recommend that you refer
to the following steps of my test:
1. Assume that you have the following stored procedure in AdventureworksDW:
CREATE PROCEDURE usp_getInternetSales
(
@productKey int
)
AS
SELECT SalesOrderNumber, SalesOrderLineNumber, RevisionNumber,
OrderQuantity,UnitPrice,ExtendedAmount,DiscountAmount
FROM dbo.FactInternetSales WHERE ProductKey=@productKey
2. In your project, create a new report and add the datasource and dataset
which contains your stored procedure.
3. Drag the columns in the dataset to your report and select Report->
Report Parameters... from the top menu, click Add to add a parameter with
the name "productKey", data type "Integer" and Prompt "product key". Then
click OK.
4. Click your reportviewer control and choose your report for the control;
5. You can write the following code in your project to set parameter:
===================================
this.usp_getInternetSalesTableAdapter.Fill(this.AdventureWorksDWDataSet.usp_
getInternetSales, Int32.Parse(this.txtProductKey.Text));
ReportParameter p = new
ReportParameter("productKey",this.txtProductKey.Text);
this.reportViewer1.LocalReport.SetParameters(new
ReportParameter[] { p });
this.reportViewer1.RefreshReport();
=======================================
You may also refer to the following article:
Defining Report Parameters in a ReportViewer Report
http://msdn.microsoft.com/en-us/library/ms251685(VS.80).aspx
Hope this helps. If you have any other questions or concerns, please feel
free to let me know. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================
Charles Wang [MSFT] - 16 May 2008 10:53 GMT
Hi Peer,
Just check with you to see if the suggestions were helpful. Please feel
free to let us know if you would like further assistance.
Have a great day!
Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
=========================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================
Charles Wang [MSFT] - 20 May 2008 04:02 GMT
Hi Peer,
Just add a comment here, if you were setting the parameters to the server
report programmatically, you can refer to the following code:
reportViewer1.ProcessingMode = ProcessingMode.Remote;
reportViewer1.ServerReport.ReportServerUrl = new
Uri("http://remoteserver/reportserver");
reportViewer1.ServerReport.ReportPath = "/AdventureWorks
Reports/InternetSales";
ReportParameter p = new
ReportParameter("productKey",this.txtProductKey.Text);
this.reportViewer1.ServerReport.SetParameters(new ReportParameter[]
{ p });
this.reportViewer1.RefreshReport();
We appreciate your posting back and let us know if you need further
assistance on this issue. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
=========================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================