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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP - How to show paramter fields from the Crystal Report 8.5 report? 1

Status
Not open for further replies.

dzu

Programmer
Sep 12, 2001
5
DE
Hello,

I want using ASP to call reports (version Crystal Reports 8.5) in a
local network. The reports based of a database on a sql-server.
With the following code I can access of my reports, but I have this
problem: in some reports I use crystal parameter fields, so that the
user can set a select parameter, but it is not stringent necessary.
(Only) the reports with parameter fields dont get displayed - no
parameter field, no report. What can I do?

<%
' Get QS variables
rpttoview = request.querystring(&quot;rpt&quot;)
viewer = request.querystring(&quot;init&quot;)

'build full path for report
rpttoview = MID(request.ServerVariables(&quot;PATH_TRANSLATED&quot;),
1, (LEN(request.ServerVariables(&quot;PATH_TRANSLATED&quot;))-11)) &
&quot;\myreportdirectory\&quot; & rpttoview & &quot;.rpt&quot;

' build path to database
myConnStr=&quot;Driver={SQL
Server};server=myservername;PWD=userpassword;UID=username;
Database=databasename&quot;

set conntemp=server.createobject(&quot;adodb.connection&quot;)
conntemp.open myConnStr

' Only create the Crystal Application Object on first time through
If Not IsObject ( session (&quot;oApp&quot;)) Then
Set session (&quot;oApp&quot;) =
Server.CreateObject(&quot;Crystal.CRPE.Application&quot;)
End If

' Turn off all Error Message dialogs
Set oGlobalOptions = Session (&quot;oApp&quot;).Options
oGlobalOptions.MorePrintEngineErrorMessages = 0

' Open the report
Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(rpttoview)

' Turn off sepecific report error messages
Set oRptOptions = Session(&quot;oRpt&quot;).Options
oRptOptions.MorePrintEngineErrorMessages = 0

' now set the table location
'Set oDB = session(&quot;oRpt&quot;).Database
'For Each oDBTable In oDB.Tables
' oDBTable.Location = conntemp
'Next

' Opening the page engine will cause the data to be read
Set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine

' Now decide what viewer to create
Select Case viewer
Case &quot;java&quot;
%>

<applet
ALIGN = LEFT
code=ReportViewer.class
codebase=&quot;/viewer/JavaViewer&quot;
id=ReportViewer
width=100%
height=95%>
<param name=ReportName value=&quot;rptserver.asp&quot;>
</applet>

<%
Case &quot;actx&quot;
%>
<OBJECT ALIGN = LEFT ID=&quot;CRViewer&quot; WIDTH=100%
HEIGHT=95%
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;

CODEBASE=&quot;/viewer/activeXViewer/CRViewer.dll#Version=1,2,0,30
&quot;>
<PARAM NAME=&quot;Report Name&quot; VALUE=&quot;rptserver.asp&quot;>
<PARAM NAME=&quot;Show Group Tree&quot; VALUE= 1>
<PARAM NAME=&quot;Show Toolbar&quot; VALUE= 1>
</OBJECT>

<%
Case &quot;html_frame&quot;
response.redirect &quot;htmstart.asp&quot;
Case &quot;html_page&quot;
response.redirect &quot;rptserver.asp&quot;
end select
%>

Thanks for your help.
dzu
 
Hi DZU,

First of all, why are you using &quot;Crystal.CRPE.Application&quot; to create Crystal runtime object. If you are using 8.5 on the server you should be using &quot;CrystalRuntime.Application&quot;.

But it is different matter. In the code you pasted, where are you filling and passing ParameterFields collection of the report? Or I think you want to know the same.

After setting the calling OpenReport and setting the options, you need to decide which of your reports need to be fed with ParameterFields collection? You can take this decision in Select Case construct based on name of the report. Obviously you will have to hardcode this thing.

You need to do something like this:
<<<<<
set session(&quot;CRCol&quot;) = Session(&quot;oRpt&quot;).Parameterfields

set CRCustParam = session(&quot;CRCol&quot;).item(1)
Call CRCustParam.SetCurrentValue (CStr(&quot;Cedric&quot;), 12)

set CRCustParam2 = session(&quot;CRCol&quot;).item(2)
Call CRCustParam2.SetCurrentValue (CStr(&quot;Pioline&quot;), 12)

Like this all the parameters you have to pass in the sequence expected by the report.
>>>>>

For your stringent exception (reports that do not need parameterfields), it is just smooth sailing. You do not need to do anything like the code above. But suppose your report needs dynamic query kind of thing, and then you need to build the query dynamically and set it as following.

<<<<<
session(&quot;oRpt&quot;).SQLQueryString = cstr(strSt)

Here strSt is the query you will build in your page according to the query string parameters.
>>>>>

Get back if I got you wrong.

Have Fun,
Malay M. Thakershi
mthakershi@yahoo.co.in
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top