ReportViewer parameter arrays cannot be declared with 'new'

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,<o:p></o:p>
I have an application that I am changing to use ReportViewer instead of Crystal Reports. I have many variables with values that are calculated a run time based on choices that the user makes. I need to pass the values for these variables to the ReportViewer and I am doing that by setting the values for parameters that I create in the rdlc Parameters folder under Report Data and then passing the values to the report. <o:p></o:p>
Since I have many of these variables (200+), I wanted to try to keep them organized by names that would mean something to me when I see them. So I started setting the parameter names and values in arrays.<o:p></o:p>
Everything worked fine with the first array but, when I added the second array, I got an error message as show below. On researching the error, it looks like I may have to declare the arrays with "New" somehow but when I have tried, I get "ReportViewer parameter arrays cannot be declared with new.<o:p></o:p>
Can someone
tell me how to fix this code?<o:p></o:p>

Thank you,<o:p></o:p>
Dan<o:p></o:p>
PrivateSub ReportViewerTEST_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim ProjInfo(13)As Microsoft.Reporting.WinForms.ReportParameter
ProjInfo(0) = New Microsoft.Reporting.WinForms.ReportParameter("ProjName", gsProjName)
ProjInfo(1) = New Microsoft.Reporting.WinForms.ReportParameter("ProjAddress", gsProjAddress)
ProjInfo(2) = New Microsoft.Reporting.WinForms.ReportParameter("ProjCSZ", gsProjCSZ)
ProjInfo(3) = New Microsoft.Reporting.WinForms.ReportParameter("JobNo", gsProjNo)
ProjInfo(4) = New Microsoft.Reporting.WinForms.ReportParameter("CalcNo", gsCALCno)
ProjInfo(5) = New Microsoft.Reporting.WinForms.ReportParameter("CalcDate", Now.Date)
ProjInfo(6) = New Microsoft.Reporting.WinForms.ReportParameter("PrepName", gsPrepName)
ProjInfo(7) = New Microsoft.Reporting.WinForms.ReportParameter("PrepCoName", gsPrepCoName)
ProjInfo(8) = New Microsoft.Reporting.WinForms.ReportParameter("PrepAddress", gsPrepAddress)
ProjInfo(9) = New Microsoft.Reporting.WinForms.ReportParameter("PrepCSZ", gsPrepCSZ)
ProjInfo(10) = New Microsoft.Reporting.WinForms.ReportParameter("PrepPhone", gsPrepPhone)
ProjInfo(11) = New Microsoft.Reporting.WinForms.ReportParameter("PrepFax", gsPrepFax)
ProjInfo(12) = New Microsoft.Reporting.WinForms.ReportParameter("PrepEmail", gsPrepEmail)
ProjInfo(13) = New Microsoft.Reporting.WinForms.ReportParameter("PrepURL", gsPrepURL)
ReportViewer1.LocalReport.SetParameters(ProjInfo)
Dim DesignCat(18) As Microsoft.Reporting.WinForms.ReportParameter
DesignCat(0) = New Microsoft.Reporting.WinForms.ReportParameter("OccupancyCat", gsUseGroup)
DesignCat(1) = New Microsoft.Reporting.WinForms.ReportParameter("SiteClass", gsSclass)
DesignCat(2) = New Microsoft.Reporting.WinForms.ReportParameter("Ss", gdSs)
DesignCat(3) = New Microsoft.Reporting.WinForms.ReportParameter("S1", gdS1)
DesignCat(4) = New Microsoft.Reporting.WinForms.ReportParameter("Fa", (Format(gdFa," 0.00")))
DesignCat(5) = New Microsoft.Reporting.WinForms.ReportParameter("Fv", (Format(gdFv," 0.00")))
DesignCat(6) = New Microsoft.Reporting.WinForms.ReportParameter("SMS", (Format(gdSms," 0.000")))
DesignCat(7) = New Microsoft.Reporting.WinForms.ReportParameter("SM1", (Format(gdSm1," 0.000")))
DesignCat(8) = New Microsoft.Reporting.WinForms.ReportParameter("Ss-2", gdSs)
DesignCat(9) = New Microsoft.Reporting.WinForms.ReportParameter("S1-2", gdS1)
DesignCat(10) = New Microsoft.Reporting.WinForms.ReportParameter("Fa-2", (Format(gdFa," 0.00")))
DesignCat(11) = New Microsoft.Reporting.WinForms.ReportParameter("Fv-2", (Format(gdFv," 0.00")))
DesignCat(12) = New Microsoft.Reporting.WinForms.ReportParameter("SMS-2", (Format(gdSms," 0.000")))
DesignCat(13) = New Microsoft.Reporting.WinForms.ReportParameter("SM1-2", (Format(gdSm1," 0.000")))
DesignCat(14) = New Microsoft.Reporting.WinForms.ReportParameter("SDS", (Format(gdSds," 0.000")))
DesignCat(15) = New Microsoft.Reporting.WinForms.ReportParameter("SD1", (Format(gdSd1," 0.000")))
DesignCat(16) = New Microsoft.Reporting.WinForms.ReportParameter("ShortDCategory", SHTgrp)
DesignCat(17) = New Microsoft.Reporting.WinForms.ReportParameter("LongDCategory", LONGgrp)
DesignCat(18) = New Microsoft.Reporting.WinForms.ReportParameter("AppDCategory", gsSDcat)
ReportViewer1.LocalReport.SetParameters(DesignCat)
Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)

EndSub

Dan

View the full article
 
Back
Top