I used this coding which took from a forum to pass value from textbox to crystal report.I got an error in this line
crParameterFieldDefinition = crParameterFieldDefinitions.Item("@MajorName", Me.TextBox1.Text)
saying index is out of bounds
but when change the coding as this
crParameterFieldDefinition = crParameterFieldDefinitions.Item("@MajorName")
I got an error Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
Dim cryRpt As New ReportDocument
Dim report As New CrystalReport1
Dim major As String
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = report.DataDefinition.ParameterFields()
<pre lang="text"> crParameterFieldDefinition = crParameterFieldDefinitions.Item("@MajorName", Me.TextBox1.Text)
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)