Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Missing parameter field current value. Post Reply Post New Topic
Author Message
maniac
Newbie
Newbie
Avatar

Joined: 17 May 2007
Location: United States
Online Status: Offline
Posts: 28
Quote maniac Replybullet Topic: Missing parameter field current value.
    Posted: 17 May 2007 at 12:05pm

Gang:

 
This belongs in VS 2003, CRv9 forum. Sorry ...
 

I commenced new job & inherited legacy VS 2003 APPL w/ CR that wasn't working. It's crucial that I get the first report working. The APPL works fine.

 

Initially, there were 2 errors:

  • The CrystalReportViewer1 has 'error creating control' in design view.
  • When I run the application, the second error 'CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.' pops up in separate window where report should. The application runs with no bugs.

The APPL runs w/o exceptions (traced & used command window). The rpt runs w/o params; however, I need params. The report w/ params was run in CR only with no issue.

After researching the issue(s), this is the synopsis.

I initially tried to generate the rpt in design view. I fixed the ‘error creating control’:

<!--

'makes crv work in design view, but causes method missing issue if create programatically

   <runtime>

      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

            <dependentAssembly>

                  <assemblyIdentity name="CrystalDecisions.Web" publicKeyToken="692fbea5521e1304" culture="neutral" />

            <bindingRedirect oldVersion="9.1.5000.0" newVersion="9.2.3300.0"/>

         </dependentAssembly>

      </assemblyBinding>

   </runtime>

-->

The CR Viewer is referencing an older assembly which can’t be deleted, so I worked around it.

I don’t know how to format the DataBindings, so that’s a no go. I couldn’t find any material on how to pass anything in (similar to ‘eval’), so …

Since it’s better to do this programmatically, I used this code:

 

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared 'cry rep export options/params/tables

Imports CrystalDecisions.Web.CrystalReportViewerBase 'get or set login/params col

 

'cry rep

Dim CryRepView As New CrystalDecisions.Web.CrystalReportViewer

Dim CryRepParam As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition

Dim oRpt As CrystalDecisions.CrystalReports.Engine.ReportDocument

Dim xportOptions As New CrystalDecisions.Shared.ExportOptions

 

 

 

    Sub createReport()

        oSupervisor = CType(Session(Global.ssSupervisor), Supervisor)

        'checking for reportProperties object

        If Session("reportProperties") Is Nothing Then

            oReportP.reportname = Request.QueryString("rn")

        Else

            oReportP = CType(Session("reportProperties"), ReportProperties)

        End If

        Select Case oReportP.reportname

 

            'crv works but exposes few cls, programmatic better

 

        Case "CDL_CityDriverList"

                'Get login info

                Dim CryRepLogin As TableLogOnInfo 'login into cry rep

                Dim CryParamFldDef As ParameterFieldDefinition

                Dim rpt As New CDL_CityDriverList

                For Each CryRepTable As Table In rpt.Database.Tables 'declare/loop @ cry rep tables

                    CryRepLogin = CryRepTable.LogOnInfo 'col @ login info

                    CryRepLogin.ConnectionInfo.UserID = ConfigurationSettings.AppSettings("SqlUser") 'reuse

                    CryRepLogin.ConnectionInfo.Password = ConfigurationSettings.AppSettings("SqlPassword") 'reuse

                    CryRepTable.ApplyLogOnInfo(CryRepLogin) 'login

                    'set CryRepParFlds b4 ReportSource; else prompt @ params, init err

                Next 'table

                Dim pFld As New ParameterField

                Dim pFlds As New ParameterFields

                Dim pDisVal As New ParameterDiscreteValue

                'requestorssn

                pFld.ParameterFieldName = "requestorssn"

                pDisVal.Value = "ssn"

                pFld.CurrentValues.Add(pDisVal)

                pFlds.Add(pFld)

                'dept

                pFld.ParameterFieldName = "dept"

                pDisVal.Value = "dept"

                pFld.CurrentValues.Add(pDisVal)

                pFlds.Add(pFld)

                'add

                CryRepView.ParameterFieldInfo = pFlds

                CryRepView.ReportSource = "C:\Inetpub\wwwroot\CDL\Reports\CDL_SuspendedDriversList.rpt"

                'rpt 'pass rep @ crv

                Page.FindControl("Form1").Controls.Add(CryRepView) 'add crv @ page

                Exit Sub 'avoid reps below

    End Sub

 

The initial & current err is #2 above.

Thank you in advance for prompt professional reply (paid or otherwise).



Edited by maniac - 17 May 2007 at 12:42pm
A+ BS MCSE OOP Security+ Web Developer
Get creative, not even.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 17 May 2007 at 1:23pm
Ok, there's a lot of code here and it looks like various declarations were declared outside of this. So it will take a while to debug your app. But the first problem I see is that you are mixing the ReportDocument object model with the viewer object model. This is a no go. Can't do it. You are using the ReportDocument to assing the login credentials and then assigning the parameters to the viewer object. CR will ignore any changes made to the viewer object because the ReportDocement will override them. So you have to use the ReportDocument object model the ENTIRE time. Forget the viewer, it's lame anyway.

Secondly, I always recommend using formulas over parameters anyday. They give you almost identical functionality and formulas are trivial to program with .NET. Just use the following code to override a formula value:
myReport.DataDefinition.FormulaFields("formulaname") = "..."

See that? Piece of cake. Replace your parameters with formulas, get rid of all the code you wrote and you're good to go.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 17 May 2007 at 1:25pm
Oh yeah - one more good rule of thumb. Store the report object to the Session() collection. This optimizes your web page because teh report doesn't have to get rebuilt each time and it also prevents CR from doing funky things with page numbers as it reloads the report on every refresh. The code is similar to what you are already doing. First check if the Session() object is Nothing and create the report if so. Otherwise pull it out of the Sesion() collection and cast it as a ReportDocument class.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
maniac
Newbie
Newbie
Avatar

Joined: 17 May 2007
Location: United States
Online Status: Offline
Posts: 28
Quote maniac Replybullet Posted: 17 May 2007 at 2:27pm
Brian:
 
Thanx ... will review tomorrow when fresh. You rock!
: )
 
PS The book is on the way.
 
Shipping estimate for these items:  May 21, 2007
1 "Crystal Reports .NET Programming"
A+ BS MCSE OOP Security+ Web Developer
Get creative, not even.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.