官方找到了例子，也是这样用的 Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.11") 为什么不行啊？还是报无效的ProgID~~
'Create the Crystal Reports Objects
'You will notice that the Crystal Reports objects are scoped as session variables.
'This is because the page on demand processing is performed by a prewritten
'ASP page called "rptserver.asp". In order to allow rptserver.asp easy access
'to the Crystal Report objects, we scope them as session variables. That way
'any ASP page running in this session, including rptserver.asp, can use them.
' CREATE THE APPLICATION OBJECT
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.11")
'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.
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
'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)
'OPEN THE REPORT (but destroy any previous one first)
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
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
'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. By destroying the application and report objects
'on failure we ensure that this client session will be able to run reports when a license is free.
'Notice that we do not create the report object only once. This is because
'within an ASP session, you may want to process more than one report. The
'rptserver.asp component will only process a report object named session("oRpt").
'Therefore, if you wish to process more than one report in an ASP session, you
'must open that report by creating a new session("oRpt") object.
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
'These lines disable the Error reporting mechanism built into the
'Crystal Report Design Component automation server (craxdrt.dll).
'This is done for two reasons:
'1. The print engine is executed on the Web Server, so any error messages
' will be displayed there. If an error is reported on the web server, the
' print engine will stop processing and you application will "hang".
'2. This ASP page and rptserver.asp have some error handling logic designed
' to trap any non-fatal errors (such as failed database connectivity) and
' display them to the client browser.
'**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 recommend 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).