' CREATE THE APPLICATION OBJECT
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.11")
End If
'This "if/end if" structure is used to create the Crystal Reports Application
'object only once per session. Creating the application object - session("oApp")
'loads the Crystal Report Design Component automation server (craxdrt.dll) into memory.
'
'We create it as a session variable in order to use it for the duration of the
'ASP session. This is to eliminate the overhead of loading and unloading the
'craxdrt.dll in and out of memory. Once the application object is created in
'memory for this session, you can run many reports without having to recreate it.
' CREATE THE REPORT OBJECT
'
'The Report object is created by calling the Application object's OpenReport method.
[COLOR=red]
>>>>>>>>>>>>>>>>>>>>>Use explicit Path location not Request Server Variables>>>>>>>>>>>>
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend [/color]
'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: [URL unfurl="true"]http://Domain/Dir)[/URL]
'OPEN THE REPORT (but destroy any previous one first)
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if
On error resume next
Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.
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
'This On error resume next block checks for any errors on creating the report object.
'We are specifically trapping for an error if we try to surpass the maximum concurrent
'users defined by the license agreement.