Solved

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

Posted on 2006-07-17
4
4,651 Views
Last Modified: 2008-01-09
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
Comment
Question by:drees727
  • 2
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
frodoman earned 125 total points
ID: 17125113
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
 

Author Comment

by:drees727
ID: 17125195
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
 

Author Comment

by:drees727
ID: 17125264
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
 
LVL 42

Expert Comment

by:frodoman
ID: 17125389
Glad to help.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now