My team now hosts many websites with .rpt files and we use
Crystal Reports 10 Report Application Server (RAS), aka Crystal Reports Enterprise 10 Embedded
under Windows Server 2003.
We plan to upgrade to SAP Crystal Reports 2011 under Windows Server 2008 R2.
Applications now use ASP Classic code like the following to display reports
from within their applications using the obsolete RDC programing interface.
http://cnn304.gov.ab.ca/ctopc/crystal.asp
My question is - what is the equivalent VB.NET (ASP.NET 4.0) code to
display the same report file (CrystalRASTest.rpt) using Crystal Reorts 2011?
crystal.asp
<%
' This report is called from:
' http://cnn304.gov.ab.ca/ctopc/crystal.asp
'=====================================================================
reportname = "CrystalRASTest.rpt"
%>
<!-- #include file="CrystalRequiredSteps.asp" -->
<!-- #include file="CrystalReportsViewer.asp" -->
CrystalRequiredSteps.asp
<%
'===================================================================================
'Create the Report Application Object and Report Client Document
'===================================================================================
'
' The Crystal Reports object is scoped as a session variable.
' CREATE THE APPLICATION OBJECT
Dim ClientDoc, ObjFactory, RptAppSession
Set ObjFactory = CreateObject("CrystalReports10.ObjectFactory.1")
'Create the ReportAppSession which allows communication to the Report Application Server
Set RptAppSession = ObjFactory.CreateObject("CrystalReports.ReportAppSession")
If Err.Number <> 0 Then
Response.Write "Failed to create CrystalReports.ReportAppSession."
Response.Write "Error message: " & Err.Description
Err.Clear
End If
' Initialize the Report Application Session
RptAppSession.Initialize
If Err.Number <> 0 Then
Response.Write "Failed to initialize ReportAppSession."
Response.Write "Error message: " & Err.Description
Err.Clear
End If
' CREATE THE REPORT OBJECT
'The Report object is created by calling the ReportClientDocuments object's OpenReport method.
'This "While/Wend" loop is used to determine the physical path (eg: C:\) to the
'Crystal Report file by translating the URL virtual path (eg: http://Domain/Dir)
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
'Create a new ReportClientDocument object for this ReportAppSession.
Set ClientDoc = RptAppSession.CreateService("CrystalReports.ReportClientDocument")
If Err.Number <> 0 Then
Response.Write "Failed to create ReportClientDocument."
Response.Write "Error message: " & Err.Description
Err.Clear
End If
'Open the report obejct to initialize the ReportClientDocument
clientDoc.Open Path & "\" & reportname
If Err.Number <> 0 Then
Response.Write "Failed to open report """ & ReportPath & """"
Response.Write "Error message: " & Err.Description
Err.Clear
End If
'**IMPORTANT** Even though we disable the extended error messaging of the engine
'fatal errors can cause an error dialog to be displayed on the Web Server machine.
'For this reason we reccomend that you set the "Allow Service to Interact with Desktop"
'option on the "World Wide Web Publishing" service (IIS service). That way if your ASP
'application freezes you will be able to view the error dialog (if one is displayed).
%>
CrystalReportsViewer.asp
%
'===================================================================================
'INSTANTIATE THE VIEWER AND DISPLAY THE REPORT THROUGH THE CRYSTAL REPORTS VIEWER
'===================================================================================
Response.ExpiresAbsolute = Now() - 1
Session.CodePage = 65001 ' UTF-8
' Create the Crystal Reports Viewer
Dim viewer
Set viewer = ObjFactory.CreateObject("CrystalReports.CrystalReportViewer")
viewer.Name = "Crystal Reports Viewer"
viewer.IsOwnForm = true
viewer.IsOwnPage = true
'Set the source for the viewer to the ReportClientDocument's report source
viewer.ReportSource = clientDoc.ReportSource
'Process the http request to view the report
viewer.ProcessHttpRequest Request, Response, Null
'ReportClientDocument will be automatically closed when clientDoc is released
%>