Here's the error message..
Unable to cast object of type 'Microsoft.Reporting.WinForms.ReportParameter' to type 'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WinForms.ReportParameter]'.
Here is the code
Dim rp = New Microsoft.Reporting.WinForms.ReportParameter
Me.RV1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote
Me.RV1.ServerReport.ReportServerUrl = New Uri("http://10.1.1.138/ReportServer/")
Me.RV1.ServerReport.ReportPath = "/test/rEmailInvoice"
rp.Name = "InvoiceNumber"
rp.Values.Add("0618050")
Me.RV1.ServerReport.SetParameters(rp) < get error message here.
Me.RV1.ShowParameterPrompts = False
Me.RV1.RefreshReport()
is it that hard to set a query parameter in code? I have looked through this newsgroup, looked through MSDN, read people's blogs and still can't find the answer. Why couldn't MS create a sample that uses reportparameters?
Has anyone done this in code. Will the world end tomorrow?
Help!?!
D
Hi Maniac,
ServerReport.SetParameters method is expecting a ReportParameters collection not a single ReportParameter
here is a sample:
ReportParameter[] reportParams = new [1];
reportParams[0] = new Microsoft.Reporting.WebForms.ReportParameter("InvoiceNumber", "0618050");
RV1.ServerReport.SetParameters(reportParams);
That's it!
|||I tried your code..
Dim reportparams() As ReportParameter = New (1) <-- on the open paren I get a "Type expected" error
reportparams(0) = New Microsoft.Reporting.WinForms.ReportParameter("invoicenumber", "0618050")
Me.RV1.ServerReport.SetParameters(reportparams)
What am I missing?
|||I'm not sure of the syntax in VB but I think the syntax to declare an array of 1 element is a bit different isn'it ?
something like Dim reportParams() As new ReportParameter(1) ?
Don't know exactly how to declare an array in VB but it should be something like that
|||THANKS! for your help. I got it working..
Here's the code for anyone else who might have the this problem.
Dim reportparams(0) As ReportParameter
Me.RV1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote
Me.RV1.ServerReport.ReportServerUrl = New Uri("http://blah.blah.blah.blah/ReportServer/")
Me.RV1.ServerReport.ReportPath = "/test/remailinvoice"
reportparams(0) = New Microsoft.Reporting.WinForms.ReportParameter("InvoiceNumber", _Invoice)
'note: _Invoice is a public property
Me.RV1.ServerReport.SetParameters(reportparams)
Me.RV1.ShowParameterPrompts = False
Me.RV1.RefreshReport()
and it works!
Thanks for your help.
No comments:
Post a Comment