Does it display correctly from within Crystal?
How are you accessing it through the viewer?
Are you using VB or ASP or something else? Howard Hammerman,
Crystal Reports training, consulting, books, training material, software, and support. Scheduled training in 8 cities.
howard@hammerman.com
Dim strReportName
Dim strSubReportName
Dim strUserid
Dim strPassword
Dim objCrtable
Dim colParams
Dim objCRSubreports
Dim objCrtablesub
Dim colParams2
Dim strP1
Dim strP2
Dim strSP1
Dim strServer
Dim strDatabase
Dim objApplication
'
' CONCEPT:
'
' This application is designed to demonstrate how to define a
' record selection formula at runtime. For this example the
' selection formula is "constructed" from information from
' the calling HTML page. However all you need to do to pass
' a valid Crystal Reports Selection Formula as a string.
'===================================================================================
'Create the Crystal Reports Objects
'===================================================================================
'
'You will notice that the Crystal Reports objects are scoped as session variables.
'This is because the page on demand processing is performed by a prewritten
'ASP page called "rptserver.asp". In order to allow rptserver.asp easy access
'to the Crystal Report objects, we scope them as session variables. That way
'any ASP page running in this session, including rptserver.asp, can use them.
strP2 = Request.QueryString("rpt"
if strP2 = 0 then
strReportname = "graduate.rpt"
elseif strP2 = 1 then
strReportname = "student.rpt"
end if
strSubReportname = "BatchSummary.rpt" ' Hard code subreport name
strP1 = Request.QueryString("batchID"
strSP1 = strP1 ' set subreport parameter to the same as that of the report
%>
<title> </title>
<%
'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"
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 Report Design Component automation server (craxdrt32.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
'craxdrt32.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.
'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:
'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 & strReportname, 1)
'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.
'These lines disable the Error reporting mechanism included the built into the
'Crystal Report Design Component automation server (craxdrt32.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).
set objCrtable = session("oRpt".Database.Tables.Item(1)
objCrtable.SetLogonInfo cstr(dbserver), cstr(dbname), cstr(dbuserid), cstr(dbpasswd)
' SET PROCEDURE PARAMETER
set colParams = Session("oRpt".ParameterFields
colParams.Item(1).SetCurrentValue (CLng(strP1))
'==================================================================
' SET LOGONINFO For SUBREPORT
'==================================================================
if not isempty (strSubReportName) Then
'open the subreport
Set objCRSubreports = session("oRpt".OpenSubreport(cstr(strSubReportName))
set colParams2 = objCRSubreports.ParameterFields
colParams2.Item(1).SetCurrentValue (Clng(strSP1))
'Set Subreport logon parameters for each table in the report.
set objCrtablesub = objCRSubreports.Database.Tables.Item(1)
objCrtablesub.SetLogonInfo cstr(dbserver), cstr(dbname), cstr(dbuserid), cstr(dbpasswd)
end if
'====================================================================================
' 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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.