Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. 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 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 14th, 2004, 08:32 PM
Authorized User
 
Join Date: Dec 2004
Location: teaneck, , USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help needed Crystal Reports ASP and ActiveX Viewer

Hello,

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.
Thanks

The Code I am trying to use is

<%@Language=VBScript %>

<%
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" )
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)
Wend

'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_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
session("oRpt").ReadRecords
If Err.Number <> 0 Then
  Response.Write "An Error has occured on the server in attempting to access the data source"
Else

  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"
' 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
'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.


'
%>

<!-- #include file="ActiveXViewer.asp" --
Reply With Quote
  #2 (permalink)  
Old January 8th, 2005, 11:55 PM
Registered User
 
Join Date: Nov 2003
Location: Omaha, Nebraska, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ros1188 -

Just thought I would help you out!

1.)"I have seen some code samples on the web and tried using the following code..."

I am not sure what code samples you have been looking at on the
web but instantiating the Crystal Report object in a Session variable is completetly a wrong approach and actually consumes more resources that making a call to the object only when you need it on every page/script.

Repeat, do not use a Session var to hold a Object just set the object at the top of the script like so,

Set crObj = Server.CreateObject("CrystalRuntime.Application.9" )


2.) Also use this instrinsic ASP object to pull the physical path instead of the Request.ServerVariables(..) method you were using in your script: Use --> Server.MapPath("/")

3.) As for you main error "he following code but am getting an error Object does not support the property or method..."

The problem here I believe is that even though you have instantiated (successfully?) the Crystal Reports object in a Session var, you are trying to make a call using the Session("Options") var, which has NO WHERE in your script been remotely tied to an object or declared as possessing a value whatsoever. If you are trying to give the variable Session("options") the returned value of object method Session("oApp").Options then you would simply do this:

Code:
Session("Options") = Session("oApp").Options
or better yet like I mentioned before do not use a Session variable to instantiate an object us simple vars like the example above to look like this

Code:
Session("Options") = crObj.Options
or
Session("Options") = crObj.Method(argument a, argument b) 'respectively

That should be a solid answer for you. Also going through your code, you would easily see an error on the following line if you ticked out the IF..Then statement and left the Set Session("oRpt") = nothing because ASP will look for an object.

Best of luck.

Cheers,
Christian
Reply With Quote
  #3 (permalink)  
Old January 9th, 2005, 08:24 PM
Authorized User
 
Join Date: Dec 2004
Location: teaneck, , USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply!
I had found some code examples at business objects that directed me in the same way your response did. I was able achieve my goal.

Thanks!
Reply With Quote
  #4 (permalink)  
Old January 20th, 2005, 01:46 PM
Registered User
 
Join Date: Jan 2005
Location: St Paul, MN, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by coolpeep
 ros1188 -

Just thought I would help you out!

1.)"I have seen some code samples on the web and tried using the following code..."

I am not sure what code samples you have been looking at on the
web but instantiating the Crystal Report object in a Session variable is completetly a wrong approach and actually consumes more resources that making a call to the object only when you need it on every page/script.

Repeat, do not use a Session var to hold a Object just set the object at the top of the script like so,

Set crObj = Server.CreateObject("CrystalRuntime.Application.9" )


2.) Also use this instrinsic ASP object to pull the physical path instead of the Request.ServerVariables(..) method you were using in your script: Use --> Server.MapPath("/")

3.) As for you main error "he following code but am getting an error Object does not support the property or method..."

The problem here I believe is that even though you have instantiated (successfully?) the Crystal Reports object in a Session var, you are trying to make a call using the Session("Options") var, which has NO WHERE in your script been remotely tied to an object or declared as possessing a value whatsoever. If you are trying to give the variable Session("options") the returned value of object method Session("oApp").Options then you would simply do this:

Code:
Session("Options") = Session("oApp").Options
or better yet like I mentioned before do not use a Session variable to instantiate an object us simple vars like the example above to look like this

Code:
Session("Options") = crObj.Options
or
Session("Options") = crObj.Method(argument a, argument b) 'respectively

That should be a solid answer for you. Also going through your code, you would easily see an error on the following line if you ticked out the IF..Then statement and left the Set Session("oRpt") = nothing because ASP will look for an object.

Best of luck.

Cheers,
Christian
I have been having the same issue. Can you help me out with this? I am a bit confused on what you were saying...


Code:
<%
reportname = "Orders.rpt"

Set crObj = Server.CreateObject("CrystalRuntime.Application.10")

Path = Server.MapPath("/")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
    iLen = Len(Path) - 1
    Path = Left(Path, iLen)
Wend

'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"

set session("oRptOptions") = Session("oRpt").Options
session("oRptOptions").MorePrintEngineErrorMessages = 0

On Error Resume Next
session("oRpt").ReadRecords
If Err.Number <> 0 Then
  Response.Write "An Error has occured on the server in attempting to access the data source"
Else

  If IsObject(session("oPageEngine")) Then
      set session("oPageEngine") = nothing
  End If
set session("oPageEngine") = session("oRpt").PageEngine
End If

%>
Reply With Quote
  #5 (permalink)  
Old January 20th, 2005, 11:25 PM
Authorized User
 
Join Date: Dec 2004
Location: teaneck, , USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have earlier posted a reply on the following location for Crystal Reports Version 9. The database I used was oracle 9i. I used the examples given by business objects to use with the RDC of Crystal Reports 9.
http://p2p.wrox.com/topic.asp?TOPIC_...al,reports,ASP

I hope this link gives you the answer. If not give me specific errors may be I can help!

Ros1188
Reply With Quote
  #6 (permalink)  
Old January 20th, 2005, 11:32 PM
Authorized User
 
Join Date: Dec 2004
Location: teaneck, , USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following link provides with examples when using CR10

http://support.businessobjects.com/c...spzone_default

Ros1188
Reply With Quote
  #7 (permalink)  
Old January 24th, 2005, 06:11 PM
Registered User
 
Join Date: Jan 2005
Location: St Paul, MN, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

none of those worked for me.

Reply With Quote
  #8 (permalink)  
Old January 25th, 2005, 12:19 AM
Registered User
 
Join Date: Jan 2005
Location: , , Indonesia.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koecrit
Default

Quote:
quote:Originally posted by ros1188
 The following link provides with examples when using CR10

http://support.businessobjects.com/c...spzone_default

Ros1188
hi,..
i've download sample code from url you gave (sample code to use crystal report 10 in asp), but when i try to execute...i just get white blank display monitor, without any data show off, 'n there isnt any error message too. This what make me confused :( do you have any solution for me ?

thanks

Reply With Quote
  #9 (permalink)  
Old January 25th, 2005, 05:08 AM
Authorized User
 
Join Date: Dec 2004
Location: teaneck, , USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

koecrit,

Which one of the several examples given was used by you?
I donot see any difference in the code. It is identical to the code given with the examples for cr9, Most probably the way in which you are providing the database authentication is wrong.

Also put your report with in the same folder in which you have placed all the other files from a particular example(say Begin Here). You may even try putting the DSN name and the Database Name before providing your user ID and Password. If you are using oracle then teh database name should not be provide ie supply the DSN, UserID and Password only not the database name in the asp code.

Are you able to execute Begin Here example correctly after downloading it or getting the same type of error?
Reply With Quote
  #10 (permalink)  
Old January 25th, 2005, 11:19 PM
Registered User
 
Join Date: Jan 2005
Location: , , Indonesia.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koecrit
Default

hi ros,
thanks 4 reply...

i already extract source code i've download from url u gave, then make new virtual directory and pointing to directory where i extracted the ASP code.

Yes, the report is still in the same directory with asp file, i dont make any changes in the file. when i try to execute "BehinHere" example(just execute without change on the file), i dont get any data displayed, i just get white blank display monitor without any error message. When i try to execute the report itself, with crystal report 10, i can see the data displayed.
This what make me confused, is there i've to setting with my browser ?
for your concern, i use IE 5.

i wait for your solution, i hope it can solve my problem.

thanks you, ros



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with Crystal Reports Viewer in ASP.NET jaucourt Crystal Reports 2 February 24th, 2012 03:39 PM
Problem with crystal activex report viewer NagarajuK Crystal Reports 1 March 17th, 2008 06:57 PM
problem with crystal activex viewer in asp.net NagarajuK Crystal Reports 0 November 22nd, 2007 10:20 AM
asp.net with crystal activex viewer NagarajuK Crystal Reports 0 November 22nd, 2007 10:17 AM
Crystal Reports ActiveX Viewer omarmalik Crystal Reports 0 September 14th, 2006 05:39 AM



All times are GMT -4. The time now is 01:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.