Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 2nd, 2003, 04:16 AM
Authorized User
Join Date: Aug 2003
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crystal Report and ASP

hey guys can u tell me how to call crystal reports in ASP?
what is the procedure actually?
is it like to call activex control ?
can i get sample code somewhere?
will it work with only IE?
will this report come inside browser only or in some other format?
Please let me know
thanks and regards
Old September 3rd, 2003, 12:27 AM
Authorized User
Join Date: Jul 2003
Location: Athens, , Greece.
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts

At first, Crystal Reports has its own object for generating the report. If you have installed Crystal there is lots of ASP sample code (..at least in CR 7, there is). Crystal has 4 viewers and one of them is ActiveX Viewer (..apart from Java, HTML and framed HTML). ActiveX is especially designed for IE but you can use any of those. For example if you dont want to let your Netscape users down, you have to use the HTML or Java viewer (..as ActiveX is not supported by Netscape :( ). Last, but not least, the report will come up in a browser.As for the procedure, it depends on what you want to do!
Check some sample code below

Good luck!
Kostas lagos
<%@Language=VBScript %>


reportname = "announceReport.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("Crystal.CRPE.Application")
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 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
End if

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_all")
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").MorePrintEngineErrorMessages = 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
  End If
set session("oPageEngine") = session("oRpt").PageEngine
End If                                                                
'Response.Write "An Error has occured on the server in attempting to access the data source"
'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
'Line 200
'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.


Old April 8th, 2004, 12:53 PM
Registered User
Join Date: Apr 2004
Location: New Delhi, Delhi, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nitinkpr

i have used the same code but the following erroe is coming:
Server object, ASP 0177 (0x800401F3)
Invalid ProgID

I have crystal reports in my system.
please help

Old August 20th, 2004, 12:32 AM
Registered User
Join Date: Aug 2004
Location: Kolkata, WB, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to samik_tanik Send a message via Yahoo to samik_tanik


If you are still stuck with it then you may try with different ProgId.
You may check out the same from the regedit.
Use, Set oApp = CreateObject("CrystalRuntime.Application").
I hope this will work.

By the way did you create the sub reports dynamically, if so please suggest.
I m in a fix.

Thanks n Regards,

Old May 24th, 2005, 04:26 AM
Registered User
Join Date: May 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts


I created a Crystal report and it has got few sub reports and i am passing the id to all sub reports and i am not able to view from ASP

will please some one help me to write a code that display the subreports as well


A curve that can set lot of things i.e Smile
Old January 19th, 2006, 06:09 AM
Registered User
Join Date: Jan 2006
Location: tripoly, , Libya.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

how can creat Crystal report ?
please some one help me to Explain this

Old July 10th, 2008, 08:01 AM
Registered User
Join Date: Jul 2008
Location: mumbai, mh, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

hi hrishimusale..
i like u r question ,actually i m also searching
on same topic

can u help me on same .
i don't have more idea in CR7 ..so plz help me

if possible can u send me some source code

thankx a lot

Old February 10th, 2010, 07:45 AM
Registered User
Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

hi ..i am using crystal report 9 and asp 3.0. i wan to display crystal report in my asp page..i tried for it a lot...but it gives following error.

Server object, ASP 0177 (0x800401F3)
string class invalid

.plz do needful...help me..thanx alot....

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP and crystal report apache Classic ASP Basics 0 May 12th, 2005 01:16 AM
need help on crystal report with asp raviredekar Crystal Reports 1 January 3rd, 2005 07:26 AM
Crystal Report with ASP ronbora Classic ASP Professional 0 November 15th, 2004 09:35 AM
ASP Crystal Report Lost_Found Classic ASP Professional 0 December 2nd, 2003 02:14 AM
ASP with Crystal Report quinn Classic ASP Basics 0 June 24th, 2003 11:47 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.