Hi All,
I’m hoping that someone here can help me. I tried to apply the answers above, but no luck. Also, I'm using VB, not C#. I’m a relative newbie to SSRS/MVReportViewer, & .net. I have a vb.net app that will set report parameters and send them to a “ReportViewer” widget that will in turn run a remote report that was created in VS2005 and uses SQLServer2005.
I’ve been spinning my wheels for days on some of the following questions:
- In my report query I have an IN clause (IN (@accountlist)) that is setup as a multi-value string parameter. When I set the report parameter “accountlist” to one value it works perfectly, more than one, it fails. I have tried many formats for the list – “1,2,3″ or “‘1′,’2′,’3′”, etc……….
Here’s my VB code that sets up and runs the report:
'Set the report Processing Mode
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote
'Set the Report Viewer - Server URL & Report Path
ReportViewer1.ServerReport.ReportServerUrl = New Uri("http://localhost/reportserver")
ReportViewer1.ServerReport.ReportPath = "/ljm reports/" & LJM_Reporter.ReportName
'Setup parameter collection
Dim pInfo As Microsoft.Reporting.WinForms.ReportParameterInfoCollection
Dim paramList As New Generic.List(Of Microsoft.Reporting.WinForms.ReportParameter)
'Insert parameter list - note - LJM_Reporter.AccountList is a string
paramList.Add(New Microsoft.Reporting.WinForms.ReportParameter("accountlist", LJM_Reporter.AccountList, False))
'Here are some examples of formats that have not worked
'paramList.Add(New Microsoft.Reporting.WinForms.ReportParameter("accountlist", "'0000R9Y199', '00001366W7'", False))
'paramList.Add(New Microsoft.Reporting.WinForms.ReportParameter("accountlist", '0000R9Y199','00001366W7' , False))
ReportViewer1.ServerReport.SetParameters(paramList)
'Run the Report
Me.ReportViewer1.RefreshReport()
I have come across a few postings on help sites that mentioned that a spliter (tokenize values that are in my parameter string and delimited by a comma) function (UDF) is needed for stored procedures. I am not using a stored procedure but thought this might be part of my problem anyway. My report query was created in VS2005 in the data tab of my report project. Do I need a spiter for this report query? Interestingly enough, when I run the report by itself in preview mode and input multiple values from the report parameter area on top for account_list it works.
- I’m also running into problems with the UDF function spliter. I created the function in SQL Server and it works fine. I put it into my select statement as such – “IN (SELECT item FROM dbo.fnSplit(@account_list, [,]) AS fnSplit_1)”. When I run the report I now get several errors. I get “must declare the scalar variable “@accountlist” and I also get one for another parameter for some strange reason. Since this is not a SP, I’m not sure how to resolve.
I have other questions as well, but these are the one’s that are driving me crazy at the moment. I can provide more detail if needed or my rambling is unclear.
Any advice would be greatly appreciated!
Regards,
John