Results 1 to 4 of 4

Thread: Seems silly to have to create a parameter that is already part of report?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2004
    Posts
    263

    Seems silly to have to create a parameter that is already part of report?

    I am using the following code to set a parameter in my report.

    Code:
    Dim paramList As New Generic.List(Of Microsoft.Reporting.WinForms.ReportParameter)
    
    dim TestString as string
    TestString = "hello world"
    
    paramList.Add(New Microsoft.Reporting.WinForms.ReportParameter("paramTitle", TestString))
    
    ReportViewer1.LocalReport.SetParameters(paramList)
    However, if I create the parameter at design time, it seems like I should be able to do something much simpler like

    Code:
    Microsoft.Reporting.WinForms.ReportParameter("paramTitle", TestString)
    since the parameter is already created. However, I can't get anything like that to work.

    Is this logic bad somewhere?

    Thanks,

    Dave

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Seems silly to have to create a parameter that is already part of report?

    Code:
        Imports CrystalDecisions.CrystalReports.Engine
        Imports CrystalDecisions.Shared
        '
        ' Load the selected report file.
        '
        Dim CR As New ReportDocument
        CR.Load(strReportPath)
        '
        ' Declare the parameter related objects.
        '
        Dim crParameterDiscreteValue As ParameterDiscreteValue
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldLocation As ParameterFieldDefinition
        Dim crParameterValues As ParameterValues
        '
        ' Get the report's parameters collection.
        '
        crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
        '
        ' Set the first parameter
        ' - Get the parameter, tell it to use the current values vs default value.
        ' - Tell it the parameter contains 1 discrete value vs multiple values.
        ' - Set the parameter's value.
        ' - Add it and apply it.
        ' - Repeat these statements for each parameter.
        '
        crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
        crParameterValues = crParameterFieldLocation.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        crParameterDiscreteValue.Value = strStartDate
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
        '
        ' Set the Crytal Report Viewer control's source to the report document.
        '
        CrystalReportViewer.ReportSource = CR
    If the parameters were added to your Crystal Report by clicking the Parameter Fields node in the Crystal IDE's Field Explorer they can be set using the following code:
    Code:
        Dim cr As New ReportDocument
        cr.Load(strReportPath)
        cr.SetDataSource(DS.Tables("Customers"))
        cr.SetParameterValue("StartDate", strMyParmValue)
        CrystalReportViewer.ReportSource = cr

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2004
    Posts
    263

    Re: Seems silly to have to create a parameter that is already part of report?

    jggtz, that is for a crystal report, I'm using microsoft reporting services (rdlc file)

  4. #4
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Seems silly to have to create a parameter that is already part of report?

    Oops!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width