[RESOLVED] Crystal reports - Pass parameters and change connection string
Hello guys,
I have a report which datasource is a stored procedure in a SQL2005 database. I designed the report with a parameter value as an example to view results. Now I need to send the parameter programmatically and also I need to change the connection string for the report to connect with the database.
Thanks!! :wave:
Re: [2005] Crystal reports - Pass parameters and change connection string
Hope this help:
http://www.codeproject.com/useritems..._Connectio.asp
VB Code:
Dim rpt As New crpYourReport
rpt.PrintOptions.PaperOrientation = PaperOrientation.Landscape
Try
Dim rptViewer As New frmReport
rpt.SetDataSource(mydataset.Tables(TBL_NAME))
rptViewer.crpViewer.ReportSource = rpt
Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscreteValue
paramField.ParameterFieldName = "paramname"
discreteVal.Value = modGeneral.strCompanyName
paramField.CurrentValues.Add(discreteVal)
paramFields.Add(paramField)
rptViewer.crpViewer.ParameterFieldInfo = paramFields
rptViewer.crpViewer.Zoom(7)
rptViewer.Show()
Catch Excep As Exception
End Try
Re: [2005] Crystal reports - Pass parameters and change connection string
Thanks lingsn, your code worked!!