Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys

please help me where i am wrong.. i am trying to load report in CR viewer and getting missing parameter values exception here is my code below
VB
If Not IsPostBack Then


         Dim pathandname As String
         Dim ReportName As String
         Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions

         '' ReportName = Replace(Rptname, ".rpt", ".pdf")
         ReportName = Request.QueryString("rpt").ToString()
         'ReportName = Replace(Rptname, ".rpt", ".pdf")
         pathandname = Server.MapPath("Reports/" & ReportName)

         Dim RptDocument As New ReportDocument
         Dim paramValues As New Hashtable

         RptDocument.Load(pathandname)


         paramValues = DirectCast(Session("Hashtable"), Hashtable)

         Dim keyCollection As ICollection = paramValues.Keys()
         Dim enumerator As IEnumerator = keyCollection.GetEnumerator

         While enumerator.MoveNext
             Dim param As New CrystalDecisions.Shared.ParameterField
             Dim paramValue As New CrystalDecisions.Shared.ParameterDiscreteValue
             Dim paramValTyp As New CrystalDecisions.Shared.ParameterType

             param.ParameterFieldName = CType(enumerator.Current, String)
             paramValue.Value = paramValues.Item(CType(enumerator.Current, String))
             param.CurrentValues.Add(paramValue)

             RptDocument.DataDefinition.ParameterFields(CType(enumerator.Current, String)).ApplyCurrentValues(param.CurrentValues)
             RptDocument.SetParameterValue(param.ParameterFieldName, paramValue.Value)
         End While
         ApplyConnectionInfo(RptDocument)
         CrystalReportViewer1.ReportSource = RptDocument
         CrystalReportViewer1.RefreshReport()
     End If
Posted
Updated 7-Nov-14 7:15am
v2
Comments
Kschuler 7-Nov-14 14:46pm    
How many parameters does the report have? Are you setting all of them? Try debugging and walking through the code to make sure.
wahhab123 8-Nov-14 2:54am    
report have three parameters and i have set them all, parameters are passing correctly in value and in quantity too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900