Hi guys,
I wonder if you have ever encountered this problem:
I have published a report in CE (CE10 Professional) and depending on which way I use to retrieve it I end up with all commands useless?????
This is the code used to pass parameters to the report which render the report useless:
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
Option Strict Off
Option Explicit On
Imports CrystalDecisions.Enterprise
Imports CrystalDecisions.Enterprise.Desktop
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Public Class ViewReport
Inherits System.Web.UI.Page
'Enterprise variables
Dim ceSessionmgr As New SessionMgr
Dim ceSession As EnterpriseSession
Dim ceInfoStore As InfoStore
Protected WithEvents CrystalReportViewer2 As CrystalDecisions.Web.CrystalReportViewer
Dim ceEnterpriseService As EnterpriseService
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Try
Dim spVal1 As String
Dim spVal2 As String
Dim spVal3 As String
Dim spVal4 As String
Dim spVal5 As String
Dim ceReport As Report
'grab the parameter values from the query string
spVal1 = Request.Params("division").ToString
spVal2 = Request.Params("DateFrom").ToString
spVal3 = Request.Params("Dateto").ToString
spVal4 = Request.Params("amountvalue").ToString
spVal5 = Request.Params("user").ToString
ceReport = FetchReport("CancellationAnalysisBuyer2")
'pass parameter values to the viewer control
PassParamValues(ceReport, spVal1, spVal2, spVal3, spVal4, spVal5)
'Pass the enterprise session to the viewer
CrystalReportViewer2.EnterpriseLogon = ceSession
'view the report
CrystalReportViewer2.ReportSource = ceReport
CrystalReportViewer2.Visible = True
Catch err As Exception
'error - output message
Response.Write("<b>There was an error displaying your report:</b><br>")
Response.Write(err.Message.ToString + "<br>")
Response.Write("Click <a href=Login.aspx>here</a> to return to the login page.")
End Try
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Function FetchReport(ByVal sReportName As String) As Report
Dim ceReports As InfoObjects
Dim sLogonToken As String
Dim sQuery As String
ceSession = ceSessionmgr.Logon("Administrator", "", "czc43114wk", "Enterprise")
'Create the infostore object
ceEnterpriseService = ceSession.GetService("", "InfoStore")
ceInfoStore = New InfoStore(ceEnterpriseService)
'query the infostore to get the desired object
sQuery = "select * from CI_INFOOBJECTS where SI_NAME = '" + sReportName + "' and SI_INSTANCE = 0"
ceReports = ceInfoStore.Query(sQuery)
Dim myReport As New CrystalDecisions.Enterprise.Desktop.Report(ceReports.Item(1).PluginInterface)
Return myReport
End Function
Private Sub PassParamValues(ByVal MyReport As Report, ByVal sVal1 As String, ByVal sVal2 As String, ByVal sVal3 As String, ByVal sVal4 As String, ByVal sVal5 As String)
Dim Param As CrystalDecisions.Enterprise.Desktop.ReportParameter
Dim ParamValue As CrystalDecisions.Enterprise.Desktop.ReportParameterSingleValue
Dim myParameterFields As New ParameterFields
For Each Param In MyReport.ReportParameters
ParamValue = Param.CreateSingleValue()
Select Case LCase(Param.ParameterName)
Case LCase("@DivisionId")
AddParameter(myParameterFields, "@DivisionId", sVal1)
Case LCase("@DateFrom")
AddParameter(myParameterFields, "@DateFrom", sVal2)
Case LCase("@DateTo")
AddParameter(myParameterFields, "@DateTo", sVal3)
Case LCase("@AmountValue")
AddParameter(myParameterFields, "@AmountValue", sVal4)
Case LCase("QTVUser")
AddParameter(myParameterFields, "QTVUser", sVal5)
End Select
'Clear out the current values
Param.CurrentValues.Clear()
'Add the new value
Param.CurrentValues.Add(ParamValue)
Next
CrystalReportViewer2.ParameterFieldInfo = myParameterFields
End Sub
Private Sub AddParameter(ByRef crParameterFields As ParameterFields, ByVal ParameterFieldName As String, ByVal Value As String)
Dim crParameterField As New ParameterField
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterDiscreteValue.Value = Value
crParameterField.ParameterFieldName = ParameterFieldName
crParameterField.CurrentValues.Add(crParameterDiscreteValue)
crParameterFields.Add(crParameterField)
End Sub
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
'*****Clean Up Licenses*****
If Not IsNothing(ceSessionmgr) Then
ceSessionmgr.Dispose()
End If
If Not IsNothing(ceSession) Then
ceSession.Dispose()
End If
If Not IsNothing(ceInfoStore) Then
ceInfoStore.Dispose()
End If
ceSessionmgr = Nothing
ceSession = Nothing
ceInfoStore = Nothing
ceEnterpriseService = Nothing
End Sub
End Class
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Thank you in advance for any help/advice
Mo