Hi.
I've got a asp page that calls a crystal report. At this stage the activex control is loading but no report is showing. I am sure that I've got my paths right.
Here is the code. Maybe you guys can pick up the problem.
Thanks
<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim oDom
Dim oNodeList
session("requestno") = Request.QueryString("id")
'con.Execute("spParameterM " & session("requestno") & "")
ReportName = "Report2.rpt"
'reportname = "report1.rpt"
' CREATE THE APPLICATION OBJECT
If Not IsObject (session("oApp")) Then
'Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.10")
End If
'OPEN THE REPORT (but destroy any previous one first)
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if
On error resume next
'Response.Write "Before opening report."
Set session("oRpt") = session("oApp").OpenReport("C:\crsnew\reports\" + ReportName, 1)'c:\data\report1.rpt",1)
'Response.Write "After opening report."
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.
'Response.Write Err.number
'Response.Write Err.Description
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
End If
'Response.Write "Before setting print engine info."
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
session("oRpt").DiscardSavedData
'Response.Write "Before setting report parameters."
Dim sParam
Dim sParamValue
Dim lIndex
Dim oNode
Dim crTable
Set oDom = server.CreateObject("MSXML2.DOMDOCUMENT.4.0")
oDom.loadXML (session("Parameters"))
For lIndex = 1 to Session("oRpt").Parameterfields.Count
sParam = Session("oRpt").Parameterfields(lIndex).ParameterFieldName
'Set oNode = oDom.selectSingleNode ("/REPORTPARAMETERS/PARAMETERS[@NAME='" & sParam & "']")
'sParamValue = oNode.Attributes.getNamedItem("CURRENTVALUE").nodeValue
sParamValue = session("requestno")
Select Case Session("oRpt").Parameterfields(lIndex).ValueType
Case 7
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (CDbl(sParamValue), 7)
Case 8
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (CDbl(sParamValue), 8)
Case 9
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (Cbool(sParamValue), 9)
Case 12
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (Cstr(sParamValue), 12)
Case Else
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (Cstr(sParamValue), 12)
End Select
Next
' Param Field Type VBScript Call Type Number
'
' NumberField CDbl 7
' CurrencyField CDbl 8
' Boolean CBool 9
' StringField CStr 12
'*Note* that you can not use the CDate() function to cast a variable as
'a VB Date type, then qualify that variable as type number 10 to pass
'the value as a Crystal Date. This is because a VB Date and a Crystal
'Date type are not the same. The best solution is to pass the date value
'to the Crystal Parameter field as a string type and convert the strng
'to a date in Crystal Reports using a Crystal Formula Field.
'====================================================================================
' Retrieve the Records and Create the "Page on Demand" Engine Object
'====================================================================================
'This connection to the tables are the required steps for crystal 10
Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("user ID") = "crs"
.Item("Password") = "crs"
.Item("DSN") = "Foskor"
.Item("Database") = "Foskor"
End With
Next
session("oRpt").ReadRecords
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & err.number & " - " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
End If
%>
<!-- #include file="SmartViewerActiveX.asp" -->
<%
%>
I've got a asp page that calls a crystal report. At this stage the activex control is loading but no report is showing. I am sure that I've got my paths right.
Here is the code. Maybe you guys can pick up the problem.
Thanks
<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim oDom
Dim oNodeList
session("requestno") = Request.QueryString("id")
'con.Execute("spParameterM " & session("requestno") & "")
ReportName = "Report2.rpt"
'reportname = "report1.rpt"
' CREATE THE APPLICATION OBJECT
If Not IsObject (session("oApp")) Then
'Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.10")
End If
'OPEN THE REPORT (but destroy any previous one first)
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if
On error resume next
'Response.Write "Before opening report."
Set session("oRpt") = session("oApp").OpenReport("C:\crsnew\reports\" + ReportName, 1)'c:\data\report1.rpt",1)
'Response.Write "After opening report."
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.
'Response.Write Err.number
'Response.Write Err.Description
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
End If
'Response.Write "Before setting print engine info."
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
session("oRpt").DiscardSavedData
'Response.Write "Before setting report parameters."
Dim sParam
Dim sParamValue
Dim lIndex
Dim oNode
Dim crTable
Set oDom = server.CreateObject("MSXML2.DOMDOCUMENT.4.0")
oDom.loadXML (session("Parameters"))
For lIndex = 1 to Session("oRpt").Parameterfields.Count
sParam = Session("oRpt").Parameterfields(lIndex).ParameterFieldName
'Set oNode = oDom.selectSingleNode ("/REPORTPARAMETERS/PARAMETERS[@NAME='" & sParam & "']")
'sParamValue = oNode.Attributes.getNamedItem("CURRENTVALUE").nodeValue
sParamValue = session("requestno")
Select Case Session("oRpt").Parameterfields(lIndex).ValueType
Case 7
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (CDbl(sParamValue), 7)
Case 8
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (CDbl(sParamValue), 8)
Case 9
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (Cbool(sParamValue), 9)
Case 12
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (Cstr(sParamValue), 12)
Case Else
Call Session("oRpt").Parameterfields(lIndex).SetCurrentValue (Cstr(sParamValue), 12)
End Select
Next
' Param Field Type VBScript Call Type Number
'
' NumberField CDbl 7
' CurrencyField CDbl 8
' Boolean CBool 9
' StringField CStr 12
'*Note* that you can not use the CDate() function to cast a variable as
'a VB Date type, then qualify that variable as type number 10 to pass
'the value as a Crystal Date. This is because a VB Date and a Crystal
'Date type are not the same. The best solution is to pass the date value
'to the Crystal Parameter field as a string type and convert the strng
'to a date in Crystal Reports using a Crystal Formula Field.
'====================================================================================
' Retrieve the Records and Create the "Page on Demand" Engine Object
'====================================================================================
'This connection to the tables are the required steps for crystal 10
Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("user ID") = "crs"
.Item("Password") = "crs"
.Item("DSN") = "Foskor"
.Item("Database") = "Foskor"
End With
Next
session("oRpt").ReadRecords
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & err.number & " - " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
End If
%>
<!-- #include file="SmartViewerActiveX.asp" -->
<%
%>