VB.net Crystal Reports Multiple Parameters

Hello Experts,

I am trying to pass multiple parameters to the Crystal Report Viewer. Here is my code...

        Dim cryRpt As New ReportDocument
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        cryRpt.Load(Application.StartupPath & "\Reports\SQLTipPool.rpt")

        crParameterDiscreteValue.Value = ("2015-05-10")
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("StartDate")
        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterDiscreteValue.Value = ("2015-05-13")
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("EndDate")
        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        frm_ReportViewer.Show()
        frm_ReportViewer.CrystalReportViewer1.ReportSource = cryRpt

cryRpt.SetDatabaseLogon("dba", "pass", "sqlbase", "")

Open in new window



It wont pass the first parameter. At run time of the report, it asks me to supply it. Help?
triphenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
Try putting # # around the date or pass a real date datatype.  You are passing a string to a date it won't work.  Crystal will not do a conversion.

mlmcc
0
triphenAuthor Commented:
I should mention that only the first parameter has a problem. The second one passes just fine and it's in the exact same format. I believe it has to do with my VB.net code.
0
triphenAuthor Commented:
I got it!
   Dim cryRpt As New ReportDocument
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue
        Dim myFOpts As Integer = (CrystalDecisions.Shared.ViewerExportFormats.PdfFormat + CrystalDecisions.Shared.ViewerExportFormats.XLSXFormat + CrystalDecisions.Shared.ViewerExportFormats.CsvFormat)


        cryRpt.Load(Application.StartupPath & "\Reports\SQLTipPool.rpt")

        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
    
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("StartDate")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        crParameterDiscreteValue.Value = (MonthCalendar1.SelectionRange.Start.ToString("yyyy-MM-dd"))
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        crParameterFieldDefinition = crParameterFieldDefinitions.Item("EndDate")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        crParameterDiscreteValue.Value = (MonthCalendar1.SelectionRange.Start.AddDays(6).ToString("yyyy-MM-dd"))
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        crParameterValues.Clear()

        frm_ReportViewer.CrystalReportViewer1.AllowedExportFormats = myFOpts
        cryRpt.SummaryInfo.ReportTitle = Replace("TipPool " & MonthCalendar1.SelectionRange.Start.ToString("yyyy-MM-dd"), "", "") & ".pdf"

        frm_ReportViewer.Show()
        frm_ReportViewer.CrystalReportViewer1.ReportSource = cryRpt





        cryRpt.SetDatabaseLogon("dba", "pass", "sqlbase", "")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
triphenAuthor Commented:
I figured it out. See my last post.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.