Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem in viewing Crystal reports from ASP....

Status
Not open for further replies.

mudigal

Programmer
Dec 22, 2005
1
GB
Hi,

I am trying to view the crystal reports through ASP, when I run the asp I just see only the Crystal report tools but not the report.... no error are logged ... when I debugged through trace and found that it is fetching data from database and even loads "WebReportBroker.WebReportBroker"
but it doesnot reach rptserver.asp
The code is as follows...

ASP code where data from db is fetched and set to crystal report file....

Thanks
raj

<%@LANGUAGE="VBScript"%>
<%
'***************************************************************************************************
' Purpose: Generates the report for Deal Ticket (via Crystal Reports ActiveX Smart Viewer)
'
' Effects: N/A
'
' In: Deal_ID - parameter column restriction value taken from the calling form.
'
' Out: N/A
'
' UPDATE HISTORY:
' Ver. Date By Change(s)
'***************************************************************************************************
'===================================================================================================
' Declare variables
'===================================================================================================

Dim intDealID ' Holds the required Input parameter for the deal ID number
Dim strReportName ' Holds the Crystal Report name to be referenced
Dim strPath ' Holds the file path to the report
Dim arrRs ' Array used to hold Recordsets returned by CustomDealSet Report method

'===================================================================================================
' Declare constants
'===================================================================================================

Const adOpenDynamic = 2 ' Indicates the use of a dynamic cursor
Const adLockOptimistic = 3 ' Indicates optimistic locking
Const adInteger = 3 ' Indicates a four-byte signed integer

'===================================================================================================
' Update input parameters passed from calling function
'===================================================================================================

' Read data from the posted form using the HTTP header
intDealID = Request.QueryString ("DealID") ' Used to pass to CustomDealSet Report method

'===================================================================================================
' Create CustomDealSet object, and call CustomDealSet.Report, which shall return an array
' of Recordsets
'===================================================================================================
' Create Deal object
If Not IsObject (objDeal) Then ' PR 1135 was originally CustomDealSet
Set objDeal = Server.CreateObject ("--DCOM component--")
End If

arrRs = objDeal.Report(intDealID)
set objDeal = nothing

'===================================================================================================
' Create the Crystal Reports Objects
'===================================================================================================

' Create the Crystal Reports Application object only once per session.
' Creating the application object - session("oApp")loads the Crystal Report Design
' Component automation server (craxdrt32.dll) into memory.
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
End if

' Set the name of the Crystal Report to be opened
strReportName = "DealTicket"
strReportName = strReportName & ".rpt"

' Create the Report object, used to determine the physical path (eg: C:\) to
' the Crystal Report file by translating the URL virtual path (eg: strPath = Request.ServerVariables("PATH_TRANSLATED")
While (Right(strPath, 1) <> "\" And Len(strPath) <> 0)
intLen = Len(strPath) - 1
strPath = Left(strPath, intLen)
WEnd

' Open the report (but destroy any previous one first)
If IsObject(session("oRpt")) Then
Set session("oRpt") = nothing
End if

'===================================================================================================
' Create the main report object and data source
'===================================================================================================
' The Report object is created by calling the Application object's OpenReport method.
Set session("oRpt") = session("oApp").OpenReport(strPath & strReportName, 1)

' Disable the Error reporting mechanism built into the
' Crystal Report Design Component automation server (craxdrt32.dll).
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False

' Tell the report to report off of the data in the ADO recordset
session("oRpt").DiscardSavedData

' Instantiate a database collection which references the database used in the report.
Set objDatabase = session("oRpt").Database

' Instantiate a Tables collection which references the Tables of the Database object.
Set objTables = objDatabase.Tables



'===================================================================================================
' Create the table object which shall be used to populate the main report
'===================================================================================================

' Instantiates the table objects which references the tables used in the report.
Set objTable1 = objTables.Item(1)

' Create a session level Recordset to store the first RS in the array
Set session("objRS") = arrRS(0)

' The "SetPrivateData" line tells the report that it datasource is now
' the recordset. Now the report will display the data contained in the
' Recordset.
objTable1.SetPrivateData 3, session("objRS")
session("oRpt").DiscardSavedData

'===================================================================================================
' Create the table object that shall be used to populet the sub report
'===================================================================================================

'===============================================================================================
' Create and open the subreport
'===============================================================================================
Set objRADSubReport = Session("oRpt").opensubreport("RAD Details")

'===============================================================================================
' Navigate through the object model to obtain the report's table
'===============================================================================================
Set Database = session("oRpt").Database

Set Table2 = objRADSubReport.Database.Tables.Item(1)

'===============================================================================================
' Set Private Data - The 'SetPrivateData' method, instructs the report that its datasource
' is the recordset: session variable 'session("objRs1"). This recordset is constructed from
' the appropriate field in the Array of recordsets returned from CustomDealSet.Report.
' The report will then display the data contained in the session("objRs1") recordset.
'===============================================================================================
Set session("objRs1") = arrRS(1)
Table2.SetPrivateData 3, session("objRs1")

'===================================================================================================
' 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." & _
"<BR><BR>" & _
"Error Number: " & Err.Number & "<BR>" & _
"Error Source: " & Err.Source & "<BR>" & _
"Error Description: " & Err.Description
Else

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

%>
<HTML>
<HEAD>
<TITLE></TITLE>
<link REL="stylesheet" HREF="../StyleSheets/RTX-Styles.css" TYPE="text/css">

<!-- #include file="inc/clientCrystalViewerSupportScript.asp" -->

</HEAD>
<BODY CLASS="DialogFrame" LANGUAGE="VBScript" SCROLL="NO" ONLOAD="Page_Initialize">
<CENTER>
<OBJECT ID="CRViewer"
CLASSID="CLSID:C4847596-972C-11D0-9567-00A0C9273C2A"
codebase="../CABS/activexviewer.cab#Version=8,0,0,371"
WIDTH="100%" HEIGHT="100%">
<PARAM NAME="EnableRefreshButton" VALUE=1>
<PARAM NAME="EnableGroupTree" VALUE=0>
<PARAM NAME="DisplayGroupTree" VALUE=0>
<PARAM NAME="EnablePrintButton" VALUE=1>
<PARAM NAME="EnableExportButton" VALUE=0>
<PARAM NAME="EnableDrillDown" VALUE=0>
<PARAM NAME="EnableSearchControl" VALUE=1>
<PARAM NAME="EnableAnimationControl" VALUE=0>
<PARAM NAME="EnableZoomControl" VALUE=1>
</OBJECT>
</CENTER>
</BODY>
</HTML>
-----------
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Page_Initialize
On Error Resume Next
Dim webBroker

<%
strScript = Request.ServerVariables("Script_Name")
lngIndex=instrRev(strScript,"/")
strScript = left(strScript,lngIndex) & "rptserver.asp"
%>

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 + "<%=strScript%>"
else
Dim webSource
Set webSource = CreateObject("WebReportSource.WebReportSource")
webSource.ReportSource = webBroker
webSource.URL = Location.Protocol + "//" + Location.Host + "<%=strScript%>"
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
Call CRViewer.Zoom(1) ' fit report to page width

MsgBox "client crystal viewer "&webSource.URL

End Sub
-->
</SCRIPT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top