新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:ASP Call Crystal Report with Store Procedure(2)

ASP Call Crystal Report with Store Procedure(2)

新客网 XKER.COM 2003-07-10 来源: 收藏本文
'ActiveXPluginViewer.asp

<html>
<head>
<title>Seagate Report Viewer Plug-In</title>
</head>
<body bgcolor=C6C6C6>
<P align="center">
<script language="javascript">
document.writeln('<EMBED name="startup"');
document.writeln('type=application/x-ssreportviewer-plugin;version=8.0.0.2');
document.writeln('Width=100% ');
document.writeln('Height=100%% ');
document.writeln('Pluginspage="/viewer/ActiveXViewer/get-npviewer.htm"');
document.writeln('Param_URL="rptserver.asp" ');
document.writeln('Param_EnableExportButton="true" ');
document.writeln('Param_EnableHelpButton="false" ');
document.writeln('Param_DisplayGroupTree="true" ');
document.writeln('Param_DisplayToolbar="true" ');
document.writeln('Param_EnableGroupTree="true" ');
document.writeln('Param_EnablePrintButton="true" ');
document.writeln('Param_EnableRefreshButton="false" ');
document.writeln('Param_EnableZoomControl="true" ');
document.writeln('>');
document.writeln('</EMBED>');
</script>
</p>
</body>
</html>

'AlwaysRequiredSteps.asp

<%
'=================================================================
' This file the ALWAYS REQUIRED STEPS for using the Automation
' Server
'

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


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


' - 2 -
' 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)

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

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

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


%>


收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐