April 14, 2008 at 8:38 am
I'm trying to use the ReportViewer in a C# project, and am having problems setting the parameters programatically.
It's got to be something really simple that I'm doing wrong.
Here's my code:
private void ViewReport()
{
string sReportServer = "MyServer";
string sReportPath = "/PathToTheReport/ReportName";
string sReportServerURL = "http://" + sReportServer + "/ReportServer";
Microsoft.Reporting.WinForms.ReportParameter[] Param;
// following line getting "Use of unassigned local variable 'Param' " error.
Param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Param1", "1");
reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
reportViewer1.ServerReport.ReportServerUrl = new Uri(sReportServerURL);
reportViewer1.ServerReport.ReportPath = sReportPath;
reportViewer1.ServerReport.SetParameters(Param);
reportViewer1.ShowParameterPrompts = false;
reportViewer1.ShowPromptAreaButton = false;
reportViewer1.RefreshReport();
}
Thanks for helping me out!
Wayne
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
April 14, 2008 at 9:06 am
Are you declaring your array properly? I'm not an expert C# developer but wouldn't it be...
Microsoft.Reporting.WinForms.ReportParameter[] Param[];
Ben Sullins
bensullins.com
Beer is my primary key...
April 14, 2008 at 9:15 am
I'm not a C# expert either... 🙁
this gets me the error:
Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.
Ben Sullins (4/14/2008)
Are you declaring your array properly? I'm not an expert C# developer but wouldn't it be...
Microsoft.Reporting.WinForms.ReportParameter[] Param[];
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
April 14, 2008 at 12:11 pm
Okay, I got it working.
It should have been:
Microsoft.Reporting.WinForms.ReportParameter[] Param = new Microsoft.Reporting.WinForms.ReportParameter[1];
WayneS (4/14/2008)
I'm not a C# expert either... 🙁this gets me the error:
Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.
Ben Sullins (4/14/2008)
Are you declaring your array properly? I'm not an expert C# developer but wouldn't it be...
Microsoft.Reporting.WinForms.ReportParameter[] Param[];
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply