set report parameters for ReportViewer control in 2005

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.
 
T

tfsmag

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top