Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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)
Posted

 
Share this answer
 
Comments
dili1234 16-Sep-13 5:20am    
What is the use of parameter and what it does?
rahulaaditya 16-Sep-13 7:49am    
Dude have you resolved your problem?If not please let me know whether you need to get the parameters values to be displayed in crystal reports or what. If possible, please elaborate your need for our better understanding inorder to help you ASAP.
dili1234 16-Sep-13 23:44pm    
Still I haven't find any solution...........
I don't know how to a give value to the parameter and also though I refereed the previous threads I could find an answer to suit my question..........
Parameters can be related to variables. We can get values and store it in parameter. Passing parameter from Db to code will avoid sql injection. Correct me if im wrong.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900