set report parameters for ReportViewer control in 2005

  • Thread starter Thread starter tfsmag
  • Start date Start date
T

tfsmag

So I used the code directly from the msdn site at
http://msdn2.microsoft.com/en-us/li...ting.webforms.serverreport.setparameters.aspx

here is my exact code

--code--
Private Sub SetReportParameters()
Dim p As New ReportParameter("userid",
Security.GetUserID().ToString())
ReportViewer1.ServerReport.SetParameters(p)
End Sub
--code--

When I use that Sub it returns this error...

--error--
Unable to cast object of type
'Microsoft.Reporting.WebForms.ReportParameter' to type
'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WebForms.ReportParameter]'.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object
of type 'Microsoft.Reporting.WebForms.ReportParameter' to type
'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WebForms.ReportParameter]'.
--error--

Any help is greatly appreciated.
 
never mind, i found my answer, here is the code i used.

Private Sub SetReportParameters()
Dim userid As New ReportParameter("userid",
Security.GetUserID().ToString())
Dim p() As ReportParameter = {userid}
ReportViewer1.ServerReport.SetParameters(p)
End Sub
 
Back
Top