[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4668
  • Last Modified:

ASP.Net 2.0 / Visual Studio 2005 / Crystal Reports / Parameters

I have a web form with 1 text field and a button.  When I input criteria in the text field and click the button I get a "missing parameter values" message.  I'm calling the parameters before I open the report so I'm not sure why I'm getting this message.  I have EnableParameterPrompt set to 'False'.  If I set it to 'True', I get "The report you requested requires further information".  Any suggestions?  Thanks!
___________________________________________________________________________________________
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

'Connect to non-secured Access database

        Dim crDatabase As Database
        Dim crTables As Tables
        Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
        Dim crTableLogOnInfo As TableLogOnInfo
        Dim crConnectionInfo As ConnectionInfo
        Dim crReport As New ReportDocument()
        crReport.Load(Server.MapPath("CrystalReport2.rpt"))

        crConnectionInfo = New ConnectionInfo()

        With crConnectionInfo
            .ServerName = "c:\CR.mdb"
        End With

        crDatabase = crReport.Database
        crTables = crDatabase.Tables

        For Each crTable In crTables
            crTableLogOnInfo = crTable.LogOnInfo
            crTableLogOnInfo.ConnectionInfo = crConnectionInfo
            crTable.ApplyLogOnInfo(crTableLogOnInfo)
        Next

        Parameters()
        MyCrystalReportViewer.ReportSource = crReport
        Me.MyCrystalReportViewer.RefreshReport()

    End Sub

    Sub Parameters()
        ' Declare variables needed to pass the parameters
        ' to the viewer control.
        Dim paramFields As New ParameterFields()
        Dim paramField As New ParameterField()
        Dim discreteVal As New ParameterDiscreteValue()
        'Dim rangeVal As New ParameterRangeValue()

        ' The first parameter is a discrete parameter with multiple values.

        ' Set the name of the parameter field, this must match a
        ' parameter in the report.
        paramField.ParameterFieldName = "FY"

        ' Set the first discrete value and pass it to the parameter
        discreteVal.Value = FY1.Text

        paramField.CurrentValues.Add(discreteVal)

        paramFields.Add(paramField)

        ' Set the parameter fields collection into the viewer control.
        MyCrystalReportViewer.ParameterFieldInfo = paramFields

    End Sub
0
drees727
Asked:
drees727
  • 2
  • 2
1 Solution
 
frodomanCommented:
Try commenting out this line:

   Me.MyCrystalReportViewer.RefreshReport()


The RefreshReport method refreshes your entire report - essentially invalidating all of the information you just supplied to the report.  When you set the report source of the viewer (  MyCrystalReportViewer.ReportSource = crReport ) the databinding happens automatically so there's no need for your RefreshReport code.

frodoman
0
 
drees727Author Commented:
I tried commenting out Me.MyCrystalReportViewer.RefreshReport() but it doesn't seem to be recognizing my database connection to nt non-secured Access database.  Now I'm getting:

The report you requested requires further information.
--------------------------------------------------------------------------------
  c:\CR.mdb  
Server name:    
Database name:    
User name:    
Password:    
 Use Integrated Security  

If I remove the 'Parameters()' line in Sub Button1_Click, I don't get the above message but I get the 'missing parameter values' message.
0
 
drees727Author Commented:
Nevermine my last post.  I forgot to change the database path before moving from development to production.  Your suggestion to remove RefreshReport() solved my problem.  Thanks for the help!!
0
 
frodomanCommented:
Glad to help.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now