Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
Hi,
i,m new in SSRS and for practice i,m passing parameter to report which accepts parameter but got exception
"An exception of type 'Microsoft.Reporting.WebForms.ReportServerException' occurred in Microsoft.ReportViewer.WebForms.dll but was not handled in user code

Additional information: The value provided for the report parameter 'ProductCategoryID' is not valid for its type. (rsReportParameterTypeMismatch)"

my code is:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

namespace Practice
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ShowReport();
        }
        public void ShowReport()
        {
            ReportViewer1.ServerReport.ReportServerUrl = new  Uri("http://xxxxxxxxx/ReportServer");
            ReportViewer1.ServerReport.ReportPath = "/Practice Reports/Parameter_Example";
            ReportViewer1.ShowParameterPrompts = false;

            ReportParameter[] param = new ReportParameter[1];
            param[0] = new ReportParameter("ProductCategoryID", "Gloves");
            ReportViewer1.ServerReport.SetParameters(param);
            ReportViewer1.ServerReport.Refresh();
            
        }
    }
}


here "ProductCategoryID" is name of attribute and "Gloves" is its value.
can please any one help me :(
thanx.
Posted
Updated 3-Feb-15 3:19am
v3
Comments
ZurdoDev 3-Feb-15 9:19am    
Are you sure the ID is not really a number, like 57 or something? And you display Gloves, but the actual ID is a number?
Hamza Javed 3-Feb-15 9:24am    
hmmmmmm
ID is actually number but i tried to Convert "ProductCategoryID" into Int but cant do.it accepts only string parameters. can you please tell me how to convert? Actually it gives me exception at: ReportViewer1.ServerReport.SetParameters(param);
ZurdoDev 3-Feb-15 9:25am    
So what happens with the same code if you pass a number instead of "Gloves"?
Hamza Javed 3-Feb-15 9:27am    
ok please wait i try
Hamza Javed 3-Feb-15 9:36am    
Thanx.......
Now i,m not getting any exception but report is keep on loading in browser and not showing any result except showing loading image of report

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900