日期:2013-05-02  浏览次数:20952 次

Come from http://support.seagatesoftware.com/

'SimpleStoredProcParam.asp

<%@ LANGUAGE="VBSCRIPT" %>
<title>Crystal Reports ASP Example - Using Stored Procedure Parameters</title>
<%
'==============================================================================
' WORKING WITH THE REPORT DESIGNER COMPONENT AND ASP TO USE STORED PROCEDURES
' AND PASS VALUES TO STORED PROCEDURE PARAMETERS
'==============================================================================
'
' CONCEPT
' The Application object (oApp) is needed so that we can create the
' report object.
' Once we have created the report object (oRpt), we can then
' gain access to such things the "DatabaseParameters" in that
' report.
'
' ALWAYS REQUIRED STEPS (contained in AlwaysRequiredSteps.asp)
' - create the application object
' - create the report object
' - open the report
'
' WORK WITH STORED PROCEDURE PARAMETERS
' - get the database in the report
' - get the database's Stored Procedure Parameters
' - get the specific Store Procedure Parameter
' - save the new value to the Stored Proc Param
'
' MORE ALWAYS REQUIRED STEPS
' - retrieve the records
' - create the page engine
'
' DISPLAY THE REPORT
' - display the report using a smart viewer
' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =



'==================================================================
'==================================================================
' ALWAYS REQUIRED STEPS
'
' Include the file AlwaysRequiredSteps.asp which contains the code
' for steps:
' - create the application object
' - create the report object and open the report

%>

<%
' This is the name of the report being used in this example.
' This variable is being used in the AlwaysRequiredSteps.asp
' To use a different report, change it here.

reportname = "SimpleStoredProcParam.rpt"

%>

<!-- #include file="AlwaysRequiredSteps.asp" -->

<%
' If it is easier to understand, simply delete the line above,
' and replace it with the entire contents of the file
' AlwaysRequiredSteps.asp
'==================================================================
'==================================================================
' LOG ONTO THE EXAMPLES SYTEM DSN AGAINST MS SQL SERVER "PUBS" SAMPLE DATABASE

userid = "sa"
Password= ""

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

set crtable = session("oRpt").Database.Tables.Item(1)
crtable.SetLogonInfo "Automation", "pubs", cstr(userid),cstr(Password)

'Create a System DSN called "Automation" pointing to the "pubs" database on SQL Server.
' Add your database's username and password to the SimpleStoredProcParam.asp page where indicated.
'==================================================================
'==================================================================
' WORK WITH STORED PROCEDURE PARAMETERS

' - get the datab