Solved

Crystal Reports 9 and ASP

Posted on 2004-04-19
9
396 Views
Last Modified: 2011-08-18
Hello everybody,
I've been using VB6 and Crystal for awhile now, but now I have to convert my VB application to ASP.  All of my reports are already created in Crystal Reports 9.  I just have to display them in the browser.  Here's how it's going to work and the idea is pretty simple:

User goes to an ASP page.  Clicks on the link and previews a certain report in the browser via Crystal Reports where data is driven from Access XP database.

I told you the idea is pretty simple.

Now, how do I accomplish that?  I need a working example that does exactly that.  All of my reports have multiple subreports inside of them.

Thanks
0
Comment
Question by:pushkin
  • 3
  • 2
  • 2
9 Comments
 
LVL 5

Expert Comment

by:a1x
ID: 10860996
0
 

Author Comment

by:pushkin
ID: 10862017
Thanks for your resource, but it's only for ASP.net.  I'm doing this in ASP, plus I'm new to ASP so it would be hard for me to follow in .Net.

Thanks
0
 
LVL 5

Accepted Solution

by:
a1x earned 125 total points
ID: 10862299
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:pushkin
ID: 10863275
Again, thanks for the link.  I tried it, but the ReadMe.txt says that I need Movie.dbf file, which is not included in the zip.  There is no documentation or explanation on how to get it up and running successfully.  I would like to see a working example, so I can apply the same logic to my own reports.  Thanks for the time.
0
 
LVL 4

Expert Comment

by:kssaran
ID: 10866420
Try this

set session("oRs") = Recordset

'===================================================================================
'Create the Crystal Reports Objects
'===================================================================================
' CREATE THE APPLICATION OBJECT
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
End If

' 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("oRpt") = session("oApp").OpenReport(path & reportname, 1)

session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False

'Now we must tell the report to report off of the data in the ADO recordset:

'To base a report on data from a dynamically generated ADO recordset, we must
'build the report based on the data structure of the recordset we will create.
'Then at runtime, we tell the report to report off of the data in the ADO Record set.
'The report is currently created against a database structure file (ADORecordset.ttx)
'This ttx file contains the structure of the recordset, and not the actual data.

'A Crystal Report is completely dependant on the structure of the dataset the report
'will use. Therefor it is important that your database structure (ttx file) or DSN
'reflects EXACTLY the data that is contained in the ADO recordset at runtime.

session("oRpt").DiscardSavedData

set Database = session("oRpt").Database
'Instantiates a database collection which references the database(s) used in the report.

set Tables = Database.Tables
'Instantiates a Tables collection which references the Tables of the Database object.

set Table1 = Tables.Item(1)
'Instantiates a table object which references the first table used in the report.
'In this case this table object currently refers to the ADORecordset.ttx file.

Table1.SetPrivateData 3, session("oRs")

'The "SetPrivateData" line tells the report that it datasource is now the recordset
'Now the report will display the data contained in the session("oRs") record set.
'If your report contained a subreport that was based off this or a different reordset
'you must follow the same steps above only referencing the subreport object.
'
'
'====================================================================================
' 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

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

'Pass in dynamic values (titles etc)
'Title
'session("oRpt").formulafields.item(1).text = "'All Years for Contract " & cover & " Report for " & usertext & "'"

'dim sURL
'sURL = "SmartViewerActiveX.asp?refback=" & Server.urlencode(Request.querystring("refback").item)


%>
<!--#include file="SmartViewerActiveX.htm" -->



SmartViewerActiveX.htm contains


<OBJECT id="CRViewer"
codeBase="/viewer/activeXViewer/activexviewer.cab#Version=8,0,0,224"
classid=CLSID:C4847596-972C-11D0-9567-00A0C9273C2A width="100%" height="95%"><PARAM NAME="DisplayGroupTree" VALUE="0"><PARAM NAME="DisplayToolbar" VALUE="-1"><PARAM NAME="EnableGroupTree" VALUE="-1"><PARAM NAME="EnableNavigationControls" VALUE="-1"><PARAM NAME="EnableStopButton" VALUE="-1"><PARAM NAME="EnablePrintButton" VALUE="-1"><PARAM NAME="EnableZoomControl" VALUE="-1"><PARAM NAME="EnableCloseButton" VALUE="-1"><PARAM NAME="EnableProgressControl" VALUE="-1"><PARAM NAME="EnableSearchControl" VALUE="-1"><PARAM NAME="EnableRefreshButton" VALUE="-1"><PARAM NAME="EnableDrillDown" VALUE="-1"><PARAM NAME="EnableAnimationControl" VALUE="-1"><PARAM NAME="EnableSelectExpertButton" VALUE="0"><PARAM NAME="EnableToolbar" VALUE="-1"><PARAM NAME="DisplayBorder" VALUE="-1"><PARAM NAME="DisplayTabs" VALUE="-1"><PARAM NAME="DisplayBackgroundEdge" VALUE="-1"><PARAM NAME="SelectionFormula" VALUE=""><PARAM NAME="EnablePopupMenu" VALUE="-1"><PARAM NAME="EnableExportButton" VALUE="0"><PARAM NAME="EnableSearchExpertButton" VALUE="0"><PARAM NAME="EnableHelpButton" VALUE="0"></OBJECT>

<script LANGUAGE="VBScript">
<!--
Sub Page_Initialize
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject("WebReportBroker.WebReportBroker")
if ScriptEngineMajorVersion < 2 then
window.alert "IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site."
CRViewer.ReportName = Location.Protocol + "//" + Location.Host + "/scrsamples/Web Component Server/rptserver.asp"
else
Dim webSource
Set webSource = CreateObject("WebReportSource.WebReportSource")
webSource.ReportSource = webBroker
webSource.URL = "rptserver.asp" 'Location.Protocol + "//" + location.Host + "/scrsamples/Web Component Server/rptserver.asp"
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.EnableExportButton = true
CRViewer.EnableRefreshButton = false
CRViewer.ViewReport
<%if Session("ReportDetail") = "Total" then
Response.write("CRViewer.Zoom(90)" & chr(13))
Response.write("CRViewer.DisplayGroupTree = false")
else
Response.write("CRViewer.Zoom(75)" & chr(13))
Response.write("CRViewer.DisplayGroupTree = True")
end if%>
End Sub
-->
</script>


Rgds
Sara
0
 

Author Comment

by:pushkin
ID: 10868509
Thanks for your post kssaran.  I placed your code in my asp page, but I'm getting just a gray screen with a red X in the top left corner and nothing is displaying.  What else should I change?  And what about the first line in your code,
set session("oRs") = Recordset

Do I actually assign an ADO recordset there?

Please explain.

Thanks for your time
0
 
LVL 4

Assisted Solution

by:kssaran
kssaran earned 125 total points
ID: 10873893
If you have proper Crystal Report software with you. I would request you to install Web Component Server (WCS) included with Crystal Reports. You will get all the proper working code in that as different type of web services. You can find it in the setup of crystal Report.

Thanks & Rgds
Sara
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now