I have developed a few crystal reports now I have write an ASP( I am new ro ASP) Application which uses the activeXViewer for displaying the report to the client. I have seen some code samples on the web and tried using the following code but am getting an error Object does not support the property or method
. The error is at the line: "set Session("Options") = Session("oApp").Options". Also I am using Oracle 9i as the database. Can anyone help me out with this its very urgent.
The Code I am trying to use is
reportname = "Report1.rpt"
'This line creates a string variable called reportname that we will use to pass
'the Crystal Report filename (.rpt file) to the OpenReport method.
'To re-use this code for your application you would change the name of the report
'so as to reference your report file.
'CREATE THE APPLICATION OBJECT
If Not IsObject (session("oApp")) Then
Set Session("oApp") = Server.CreateObject("CrystalRuntime.Application.9" )
'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 Reports automation server (cpeaut32.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 elimainate the overhead of loading and unloading the
'cpeaut32.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
set Session("Options") = Session("oApp").Options
Session("Options").MatchLogonInfo = 1
Set Session("oRpt") = Session("oApp").OpenReport(path & reportname, 1)
Set crtable1 = Session("oRpt").Database.Tables.Item("hosp_unit_al l")
crtable1.SetLogonInfo "icom", " ", "hr", "hr"
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.
'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").
'Therefor, 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.
set session("oRptOptions") = Session("oRpt").Options
session("oRptOptions").MorePrintEngineErrorMessage s = 0
'These lines disable the Error reporting mechanism included the built into the
'Crystal Report Print Engine (CRPE32.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 desinged
' 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 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).
' Retrieve the Records and Create the "Page on Demand" Engine Object
On Error Resume Next
If Err.Number <> 0 Then
Response.Write "An Error has occured on the server in attempting to access the data source"
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
set session("oPageEngine") = session("oRpt").PageEngine
'Response.Write "An Error has occured on the server in attempting to access the data source"
' INSTANTIATE THE CRYSTAL REPORTS SMART VIEWER
'When using the Crystal Reports automation server in an ASP environment, we use
'the same page on demand "Smart Viewers" used with the Crystal Web Report Server.
'The are four Crystal Reports Smart Viewers:
'1. ActiveX Smart Viewer
'2. Java Smart Viewer
'3. HTML Frame Smart Viewer
'4. HTML Page Smart Viewer
'The Smart Viewer that you use will based on the browser's display capablities.
'For Example, you would not want to instantiate the Java viewer if the browser
'did not support Java applets. For purposes on this demo, we have chosen to
'define a viewer. You can through code determine the support capabilities of
'the requesting browser. However that functionality is inherent in the Crystal
'Reports automation server and is beyond the scope of this demonstration app.
'We have chosen to leverage the server side include functionality of ASP
'for simplicity sake. So you can use the SmartViewer*.asp files to instantiate
'the smart viewer that you wish to send to the browser. Simply replace the line
'below with the Smart Viewer asp file you wish to use.
'The choices are SmartViewerActiveX.asp, SmartViewerJave.asp,
'SmartViewerHTMLFrame.asp, and SmartViewerHTMLPAge.asp.
'Note that to use this include you must have the appropriate .asp file in the
'same virtual directory as the main ASP page.
'*NOTE* For SmartViewerHTMLFrame and SmartViewerHTMLPage, you must also have
'the files framepage.asp and toolbar.asp in your virtual directory.
<!-- #include file="ActiveXViewer.asp" --