I have a Crystal Report that uses data sourced from 3 stored procedures in SQL Server. When I run the report via a WinForm it asks me for the parameters, even though I'm passing them through in the VB.Net code. Here's what I've got:
'Logon to the server
Dim crReport As New ContactReport()
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Dim crLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo()
ReportViewer.LogOnInfo = New CrystalDecisions.Shared.TableLogOnInfos()
crLogonInfo.TableName = "sp_CM_SelectContactForReport;1"
With crLogonInfo.ConnectionInfo
.ServerName = "(local)"
.DatabaseName = "ContactsManager"
.UserID = "xx" 'UserId
.Password = "xx" 'Password
End With
ReportViewer.LogOnInfo.Add(crLogonInfo)
'Create the parameter objects
Dim ParameterFields As New CrystalDecisions.Shared.ParameterFields()
Dim ParameterField As New CrystalDecisions.Shared.ParameterField()
Dim spValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
'Add contact ID parameter
ParameterField.ParameterFieldName = "@cnt_ID"
ParameterField.ParameterType = CrystalDecisions.[shared].ParameterType.StoreProcedureParameter
spValue.Value = intRowID
ParameterField.CurrentValues.Add(spValue)
ParameterFields.Add(ParameterField)
'Add current user ID parameter
ParameterField.ParameterFieldName = "@cnt_UserID"
ParameterField.ParameterType = CrystalDecisions.[shared].ParameterType.StoreProcedureParameter
spValue.Value = strUserID
ParameterField.CurrentValues.Add(spValue)
ParameterFields.Add(ParameterField)
ReportViewer.ParameterFieldInfo = ParameterFields
'Show the report
ReportViewer.ReportSource = crReport
The code runs all the way through, appears to add the parameters, but when the report runs it comes up with the parameter entry dialog for both parameters... anyone know what I'm missing here?
TIA...
Mike.