Hey all, I need to pass a parameter from VB.NET to my CR Report 10. After looking at some examples like this...
I have some questions. I put the crystal report viewer1 in a seperate form from where user's input the parameter. Soo what do I do about this code? Does some of this need to be in the other form, or what? I'm getting extremely confused on this, it doesnt seem easy at all.
I have the form working great, the report is ready, and the Stored Procedure that provides the source for the report... but I'm stuck on passing this parameter to vb.Net.
Code:
For passing parameter from TextBox to Crystal Report follow following steps
1)add Crystal report and viewer in your project
2)on which field u want to add parameter is let's examples "Name" Field.
3)First In report Create parameter by right click on parameter field--> Name
4)In pop up enter Name as -->paraName
5)Second In report clicked on Database field-->Table Name--> Field Name(Here "Name" )
6)Right clicked on Name field-->click on Select Exert
7)Is equal to --> parameter Name({?paraName})
Dim param1Fileds As New CrystalDecisions.Shared.ParameterFields
Dim param1Field As New CrystalDecisions.Shared.ParameterField
Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim CRYRpt1 As New CrystalReport1
param1Field.ParameterFieldName = "paraName" ' Parameter Name In Crystal Report
param1Range.Value = TextBox1.Text ' value For Parameter Field
param1Field.CurrentValues.Add(param1Range)
param1Fileds.Add(param1Field) ' To add parameter in parameterslist
CrystalReportViewer1.ParameterFieldInfo = param1Fileds 'to pass parameter inf.to CRV
CrystalReportViewer1.ReportSource = CRYRpt1 ' Assign Report Source to CRV
CrystalReportViewer1.Refresh()
CrystalReportViewer1.Visible = True
End Sub
I have some questions. I put the crystal report viewer1 in a seperate form from where user's input the parameter. Soo what do I do about this code? Does some of this need to be in the other form, or what? I'm getting extremely confused on this, it doesnt seem easy at all.
I have the form working great, the report is ready, and the Stored Procedure that provides the source for the report... but I'm stuck on passing this parameter to vb.Net.