views:

50

answers:

3

Hi, I need to pass a value as a parameter from ASP.Net application to SSRS Report.How can i do this?Can anybody help me ?

Thanks in advance.

A: 

SQL Server Reporting Services in ASP.NET

See this article explain about passing parameter to Sql reports : http://www.codeproject.com/KB/books/InputParmReport.aspx

after adding parameter you can pass the parameter as show below : this is example code for passing paramter form asp.net to reports

List<SnapshotReport> List = new SnapshotReport().GetCustomersForCountry(this.DropDownList1.SelectedValue, this.DropDownList2.SelectedValue, dcfromdate.Text);
                    ReportViewer1.LocalReport.ReportPath = "Admin\\ReportDesigns\\" + _reportID + ".rdlc";
                    if (List != null)
                    {
                        if (List.Count > 0)
                        {
                            ReportParameter ServiceName = new ReportParameter("ServiceName", this.DropDownList1.SelectedItem.Text);
                            ReportParameter[] p = { ServiceName };
                            ReportViewer1.LocalReport.SetParameters(p);
                            ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("SnapshotReport1", List));
                            isnull = false;
                        }
                    }
Pranay Rana
But i need to pass a parameter value to SSRS report from web form controls like textbox and all..
Meera
check updated answer and inform if not able to get any information
Pranay Rana
A: 

You can pass the parameter values in the URL used to get the report.

Also you should disable the "Promt user (for parameters)" in /reports/Pages/Folder.aspx for your report.

Example of setting a parameter named ParameterName: /Reports/Pages/Report.aspx?...&ParameterName=ParameterValue

Viewing Reports with a Browser

Jaroslav Jandek
Can u give me an example?
Meera
An example is right there in the post - I have just omitted the parts specific to my environment.
Jaroslav Jandek
If you have a param named `ParameterName` in your rdl, it should be available to the report rendering engine as the `=Parameters!ParameterName.Value` expression with the value `ParameterValue` passed via the url in the example.It depends whether your are using the reportManager by url or the ReportViewer control.Also if you are not rendering SSRS (just confused the terms) and using a local reporting, use what **pranay_stacker** wrote.
Jaroslav Jandek
Meera
Oh, sorry. I have assumed you are using the HTML Viewer of SSRS (dunno why).Check the article on msdn http://msdn.microsoft.com/en-us/library/aa237802.aspx (Viewing Reports with a Browser). There are other ways to do that of course.
Jaroslav Jandek
Thanks jaroslav
Meera
+1  A: 

Hello

Follow the following line and try it...

        ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://MyPC/reportserver");
        ReportViewer1.ServerReport.ReportPath = "/ReportFolder/Reportname";

        Microsoft.Reporting.WebForms.ReportParameter[] Param = new Microsoft.Reporting.WebForms.ReportParameter[3];
        Param(2) = new Microsoft.Reporting.WebForms.ReportParameter("SDATE", "02/02/2002");
        Param(1) = new Microsoft.Reporting.WebForms.ReportParameter("EDATE", "09/06/2000");
        Param(0) = new Microsoft.Reporting.WebForms.ReportParameter("TASK", 0);

        View.ReportViewer.ShowParameterPrompts = false;
        View.ReportViewer.ServerReport.SetParameters(Param);
        View.ReportViewer.ServerReport.Refresh();
Amit Patel