can someone help a newbie with .net
the code i have is working fine to pass one parameter to crystal, can someone help me pass a second parameter called "line"?

Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports OEE_NEW.Module1
Imports System.Data
Imports System.IO
Imports System.Data.SqlTypes
Imports System.Windows.Forms.DataVisualization.Charting
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Windows.Forms
Public Class FrmGraphReports
    Dim paramFields As New ParameterFields
    Dim paramField As New ParameterField
    Dim discreteVal As New ParameterDiscreteValue

 Private Sub FrmGraphReports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim rpt As New CrystalReport1() 'The report you created.
        Dim myConnection As SqlConnection
        Dim MyCommand As New SqlCommand()
        Dim myDA As New SqlDataAdapter()
        Dim myDS As New DataSet1() 'The DataSet you created.



        paramField.ParameterFieldName = "year"
        discreteVal.Value = _CRyear
        paramField.CurrentValues.Add(discreteVal)
        paramFields.Add(paramField)


 


        Try
            myConnection = New SqlConnection(connectionstring)
            MyCommand.Connection = myConnection
            MyCommand.CommandText = "SELECT * from OEEBrakeDown"
            MyCommand.CommandType = CommandType.Text
            myDA.SelectCommand = MyCommand
            myDS.EnforceConstraints = False
            myDA.Fill(myDS, "OEEBrakeDown")
            rpt.SetDataSource(myDS)


            CrystalReportViewer1.ParameterFieldInfo = paramFields

            CrystalReportViewer1.ReportSource = rpt
            Me.CrystalReportViewer1.Visible = True

        Catch Excep As Exception
            MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
End Class

I believe in your case, it is as simple as just adding another set of lines that define the parameter (lines 26~29 in your code). The ParameterFieldName would be set to a different name each time.

Not sure if it is any help to you, but I have some code that sets parameter fields in a crystal report. If it is difficult to understand, say so and I can try and comment it a little better. Good luck!

RPTtraining = New frmRptSelect
        RPTtraining.strID = Me
        Me.RPTtraining.ShowDialog()

        Dim tblRev As Data.DataTable
        tblRev = Me.DocHeaderTableAdapter.GetRevision(Me.strmodel, Me.strpart)


        'the following code sets the parameter feild in the report 
        'we must declare a bunch of stuff, then set that stuff equal to stuff
        'then we can send said stuff to the report so that it may 
        'filter some other stuff and build a report. i think.
        Dim reportSource As New levelOne
        Try
            'setup the parameters 
            Dim crParameterDiscreteValue As ParameterDiscreteValue
            Dim crParameterFieldDefinitions As ParameterFieldDefinitions
            Dim crParameterFieldLocation As ParameterFieldDefinition
            Dim crParameterValues As ParameterValues
            '
            ' Get the report parameters collection.
            '
            crParameterFieldDefinitions = reportSource.DataDefinition.ParameterFields
            If crParameterFieldDefinitions.Count > 0 Then
                ' Add parameter values
                crParameterFieldLocation = crParameterFieldDefinitions.Item("SOPNo")
                crParameterValues = crParameterFieldLocation.CurrentValues
                crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                crParameterDiscreteValue.Value = Me.strSOP
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
                ' Add a parameter value - END
            End If

            If crParameterFieldDefinitions.Count > 0 Then
                ' Add parameter values
                crParameterFieldLocation = crParameterFieldDefinitions.Item("model")
                crParameterValues = crParameterFieldLocation.CurrentValues
                crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                crParameterDiscreteValue.Value = Me.strmodel
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
                ' Add a parameter value - END
            End If

            If crParameterFieldDefinitions.Count > 0 Then
                ' Add parameter values
                crParameterFieldLocation = crParameterFieldDefinitions.Item("part")
                crParameterValues = crParameterFieldLocation.CurrentValues
                crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                crParameterDiscreteValue.Value = Me.strpart
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
                ' Add a parameter value - END
            End If

            If crParameterFieldDefinitions.Count > 0 Then
                ' Add parameter values
                crParameterFieldLocation = crParameterFieldDefinitions.Item("sop")
                crParameterValues = crParameterFieldLocation.CurrentValues
                crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                crParameterDiscreteValue.Value = Me.strSOPa
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
                ' Add a parameter value - END
            End If

            If crParameterFieldDefinitions.Count > 0 Then
                ' Add parameter values
                crParameterFieldLocation = crParameterFieldDefinitions.Item("rev")
                crParameterValues = crParameterFieldLocation.CurrentValues
                crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                crParameterDiscreteValue.Value = tblRev.Rows(0).Item("revision").ToString.Substring(tblRev.Rows(0).Item("revision").ToString.IndexOf("-") + 1)
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
                ' Add a parameter value - END
            End If

            If crParameterFieldDefinitions.Count > 0 Then
                ' Add parameter values
                crParameterFieldLocation = crParameterFieldDefinitions.Item("man")
                crParameterValues = crParameterFieldLocation.CurrentValues
                crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                crParameterDiscreteValue.Value = Me.strMan
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
                ' Add a parameter value - END
            End If

            Me.CrystalReportViewer1.ReportSource = reportSource


        Catch
        End Try
This article has been dead for over six months. Start a new discussion instead.