欢迎光临
我们一直在努力

ASP Call Crystal Report with Store Procedure(1)

建站超值云服务器,限时71元/月

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 databases 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 databases username and password to the simplestoredprocparam.asp page where indicated.

==================================================================

==================================================================

work with stored procedure parameters

– get the databases stored procedure parameters

create a variable and point it to the stored procedure parameter

in the report

set storedprocparamcollection = session("orpt").parameterfields

– get the specific store procedure parameter

create a variable and point it to the specific stored procedure

that we want to work on

set thisparam = storedprocparamcollection.item(1)

set thisparam2 = storedprocparamcollection.item(2)

set thisparam3 = storedprocparamcollection.item(3)

– save the new value to the stored proc param

create a variable and store the new value for the stored procedure

in it

newparamvalue = "10"

newparamvalue2 = "50"

newparamvalue3 = (""&a&"")

save the new value for the stored procedure in the store procedure

thisparam.setcurrentvalue cint(newparamvalue), 7

thisparam2.setcurrentvalue cint(newparamvalue2), 7

thisparam3.setcurrentvalue cstr(newparamvalue3), 12

==================================================================

==================================================================

more always required steps

– retrieve the records

– create the page engine

– create the smart viewer and point it to rptserver.asp

%>

<!– #include file="morerequiredsteps.asp" –>

<%

if it is easier to understand, simply delete the line above,

and replace it with the entire contents of the file

morerequiredsteps.asp

==================================================================

==================================================================

instantiate the report viewer

when using the crystal reports in an asp environment, we use

the same page-on-demand report viewers used with the crystal web component server.

there are six report viewers:

1. report viewer for activex

2. report viewer for java using browser jvm

3. report viewer for standard html with frames

4. report viewer for standard html

5. report viewer for java using java plugin

6. report viewer for netscape plug-in (activex)

the report viewer that you use will based on the browsers display capablities.

for example, you would not want to instantiate one of the java viewers 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 rdc 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, smartviewerjava.asp, javapluginviewer.asp,

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

=============================================================================

display the report

– display the report using a smart viewer

include one of the smart viewers.

– report viewer for activex = smartvieweractivex.asp

– report viewer for java using browser jvm = smartviewerjava.asp

– report viewer for standard html = smartviewerhtmlpage.asp

– report viewer for standard html w/ frames = smartviewerhtmlframe.asp

– report viewer for java using java plugin = javapluginviewer.asp

– report viewer for netscape plug-in = activexpluginviewer.asp

=============================================================================

%>

<!– #include file="smartvieweractivex.asp" –>

<%

==================================================================

if it easier for you to conceptualize this code by seeing it all

contained in a single file, simply delete the line above, and

replace it with the entire contents of the file being included.

==================================================================

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP Call Crystal Report with Store Procedure(1)
分享到: 更多 (0)

相关推荐

  • 暂无文章